Skip to main content

snix_castore/build/source/target/x86_64-unknown-linux-gnu/debug/build/snix-castore-6a626d437bebcd1d/out/
snix.castore.v1.rs

1// This file is @generated by prost-build.
2/// Describes more granular chunking information of a blob.
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct BlobMeta {
5    /// Contains a list of more granular chunks.
6    /// An empty list is only allowed if describing the empty blob.
7    #[prost(message, repeated, tag = "2")]
8    pub chunks: ::prost::alloc::vec::Vec<blob_meta::ChunkMeta>,
9}
10/// Nested message and enum types in `BlobMeta`.
11pub mod blob_meta {
12    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
13    pub struct ChunkMeta {
14        /// Digest of that specific chunk
15        #[prost(bytes = "bytes", tag = "1")]
16        pub digest: ::prost::bytes::Bytes,
17        /// Length of that chunk, in bytes.
18        #[prost(uint64, tag = "2")]
19        pub size: u64,
20    }
21}
22/// A Directory can contain Directory, File or Symlink entries.
23/// Each of these nodes have a name attribute, which is the basename in that
24/// directory and node type specific attributes.
25/// The name attribute:
26///
27/// * MUST not contain slashes or null bytes
28/// * MUST not be '.' or '..'
29/// * MUST be unique across all three lists
30///   Elements in each list need to be lexicographically ordered by the name
31///   attribute.
32#[derive(Clone, PartialEq, ::prost::Message)]
33pub struct Directory {
34    #[prost(message, repeated, tag = "1")]
35    pub directories: ::prost::alloc::vec::Vec<DirectoryEntry>,
36    #[prost(message, repeated, tag = "2")]
37    pub files: ::prost::alloc::vec::Vec<FileEntry>,
38    #[prost(message, repeated, tag = "3")]
39    pub symlinks: ::prost::alloc::vec::Vec<SymlinkEntry>,
40}
41/// A DirectoryEntry represents a directory.
42#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
43pub struct DirectoryEntry {
44    /// The (base)name of the directory
45    #[prost(bytes = "bytes", tag = "1")]
46    pub name: ::prost::bytes::Bytes,
47    /// The blake3 digest of a Directory message.
48    #[prost(bytes = "bytes", tag = "2")]
49    pub digest: ::prost::bytes::Bytes,
50    /// Number of child elements in the Directory referred to by `digest`.
51    /// Child directory elements are calculated by summing up the numbers of
52    /// `directories`, `files` and `symlinks`, and for each directory, its size field.
53    /// Can be used for inode number calculation.
54    /// This field is precisely as verifiable as any other Merkle tree edge.
55    /// Resolve `digest`, and you can compute it incrementally. Resolve the entire
56    /// tree, and you can fully compute it from scratch.
57    /// A credulous implementation won't reject an excessive size, but this is
58    /// harmless: you'll have some ordinals without nodes. Undersizing is obvious
59    /// and easy to reject: you won't have an ordinal for some nodes.
60    /// Historically there were implementations which calculated up to
61    /// `(2*number of elements) + (sizes of each directory element)`,
62    /// so implementations verifying this field should accept up to this
63    /// if they still expect data produced by this code.
64    #[prost(uint64, tag = "3")]
65    pub size: u64,
66}
67/// A FileEntry represents a regular or executable file.
68#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
69pub struct FileEntry {
70    /// The (base)name of the file
71    #[prost(bytes = "bytes", tag = "1")]
72    pub name: ::prost::bytes::Bytes,
73    /// The blake3 digest of the file contents
74    #[prost(bytes = "bytes", tag = "2")]
75    pub digest: ::prost::bytes::Bytes,
76    /// The file content size
77    #[prost(uint64, tag = "3")]
78    pub size: u64,
79    /// Whether the file is executable
80    #[prost(bool, tag = "4")]
81    pub executable: bool,
82}
83/// A SymlinkEntry represents a symbolic link.
84#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
85pub struct SymlinkEntry {
86    /// The (base)name of the symlink
87    #[prost(bytes = "bytes", tag = "1")]
88    pub name: ::prost::bytes::Bytes,
89    /// The target of the symlink.
90    #[prost(bytes = "bytes", tag = "2")]
91    pub target: ::prost::bytes::Bytes,
92}
93/// A Entry is either a DirectoryEntry, FileEntry or SymlinkEntry.
94#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
95pub struct Entry {
96    #[prost(oneof = "entry::Entry", tags = "1, 2, 3")]
97    pub entry: ::core::option::Option<entry::Entry>,
98}
99/// Nested message and enum types in `Entry`.
100pub mod entry {
101    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
102    pub enum Entry {
103        #[prost(message, tag = "1")]
104        Directory(super::DirectoryEntry),
105        #[prost(message, tag = "2")]
106        File(super::FileEntry),
107        #[prost(message, tag = "3")]
108        Symlink(super::SymlinkEntry),
109    }
110}
111#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
112pub struct StatBlobRequest {
113    /// The blake3 digest of the blob requested
114    #[prost(bytes = "bytes", tag = "1")]
115    pub digest: ::prost::bytes::Bytes,
116}
117#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
118pub struct StatBlobResponse {}
119#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
120pub struct GetBlobRequest {
121    /// The blake3 digest of the blob requested
122    #[prost(bytes = "bytes", tag = "1")]
123    pub digest: ::prost::bytes::Bytes,
124}
125#[derive(Clone, PartialEq, ::prost::Message)]
126pub struct GetBlobResponse {
127    #[prost(message, optional, tag = "1")]
128    pub blob_meta: ::core::option::Option<BlobMeta>,
129}
130#[derive(Clone, PartialEq, ::prost::Message)]
131pub struct PutBlobRequest {
132    /// The blake3 digest of the blob uploaded
133    #[prost(bytes = "bytes", tag = "1")]
134    pub digest: ::prost::bytes::Bytes,
135    /// Its BlobMeta
136    #[prost(message, optional, tag = "2")]
137    pub blob_meta: ::core::option::Option<BlobMeta>,
138}
139#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
140pub struct PutBlobResponse {}
141/// Generated client implementations.
142pub mod blob_store_service_client {
143    #![allow(
144        unused_variables,
145        dead_code,
146        missing_docs,
147        clippy::wildcard_imports,
148        clippy::let_unit_value,
149    )]
150    use tonic::codegen::*;
151    use tonic::codegen::http::Uri;
152    /// BlobStoreService retrieves and stores metadata about blobs.
153    /// Blobs can consist of multiple chunks.
154    /// The stored metadata describes which chunks need to be assembled
155    /// to produce the entire blob contents.
156    /// Blobs are keyed by the BLAKE3 digest of their entire data
157    #[derive(Debug, Clone)]
158    pub struct BlobStoreServiceClient<T> {
159        inner: tonic::client::Grpc<T>,
160    }
161    impl BlobStoreServiceClient<tonic::transport::Channel> {
162        /// Attempt to create a new client by connecting to a given endpoint.
163        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
164        where
165            D: TryInto<tonic::transport::Endpoint>,
166            D::Error: Into<StdError>,
167        {
168            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
169            Ok(Self::new(conn))
170        }
171    }
172    impl<T> BlobStoreServiceClient<T>
173    where
174        T: tonic::client::GrpcService<tonic::body::Body>,
175        T::Error: Into<StdError>,
176        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
177        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
178    {
179        pub fn new(inner: T) -> Self {
180            let inner = tonic::client::Grpc::new(inner);
181            Self { inner }
182        }
183        pub fn with_origin(inner: T, origin: Uri) -> Self {
184            let inner = tonic::client::Grpc::with_origin(inner, origin);
185            Self { inner }
186        }
187        pub fn with_interceptor<F>(
188            inner: T,
189            interceptor: F,
190        ) -> BlobStoreServiceClient<InterceptedService<T, F>>
191        where
192            F: tonic::service::Interceptor,
193            T::ResponseBody: Default,
194            T: tonic::codegen::Service<
195                http::Request<tonic::body::Body>,
196                Response = http::Response<
197                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
198                >,
199            >,
200            <T as tonic::codegen::Service<
201                http::Request<tonic::body::Body>,
202            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
203        {
204            BlobStoreServiceClient::new(InterceptedService::new(inner, interceptor))
205        }
206        /// Compress requests with the given encoding.
207        ///
208        /// This requires the server to support it otherwise it might respond with an
209        /// error.
210        #[must_use]
211        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
212            self.inner = self.inner.send_compressed(encoding);
213            self
214        }
215        /// Enable decompressing responses.
216        #[must_use]
217        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
218            self.inner = self.inner.accept_compressed(encoding);
219            self
220        }
221        /// Limits the maximum size of a decoded message.
222        ///
223        /// Default: `4MB`
224        #[must_use]
225        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
226            self.inner = self.inner.max_decoding_message_size(limit);
227            self
228        }
229        /// Limits the maximum size of an encoded message.
230        ///
231        /// Default: `usize::MAX`
232        #[must_use]
233        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
234            self.inner = self.inner.max_encoding_message_size(limit);
235            self
236        }
237        /// Stat checks if a \[BlobMeta\] for a given blob exists.
238        pub async fn stat_blob(
239            &mut self,
240            request: impl tonic::IntoRequest<super::StatBlobRequest>,
241        ) -> std::result::Result<
242            tonic::Response<super::StatBlobResponse>,
243            tonic::Status,
244        > {
245            self.inner
246                .ready()
247                .await
248                .map_err(|e| {
249                    tonic::Status::unknown(
250                        format!("Service was not ready: {}", e.into()),
251                    )
252                })?;
253            let codec = tonic_prost::ProstCodec::default();
254            let path = http::uri::PathAndQuery::from_static(
255                "/snix.castore.v1.BlobStoreService/StatBlob",
256            );
257            let mut req = request.into_request();
258            req.extensions_mut()
259                .insert(GrpcMethod::new("snix.castore.v1.BlobStoreService", "StatBlob"));
260            self.inner.unary(req, path, codec).await
261        }
262        /// Get retrieves a \[BlobMeta\] for a given blob digest.
263        pub async fn get_blob(
264            &mut self,
265            request: impl tonic::IntoRequest<super::GetBlobRequest>,
266        ) -> std::result::Result<
267            tonic::Response<super::GetBlobResponse>,
268            tonic::Status,
269        > {
270            self.inner
271                .ready()
272                .await
273                .map_err(|e| {
274                    tonic::Status::unknown(
275                        format!("Service was not ready: {}", e.into()),
276                    )
277                })?;
278            let codec = tonic_prost::ProstCodec::default();
279            let path = http::uri::PathAndQuery::from_static(
280                "/snix.castore.v1.BlobStoreService/GetBlob",
281            );
282            let mut req = request.into_request();
283            req.extensions_mut()
284                .insert(GrpcMethod::new("snix.castore.v1.BlobStoreService", "GetBlob"));
285            self.inner.unary(req, path, codec).await
286        }
287        /// Put persists a \[BlobMeta\] for the given blob digest.
288        pub async fn put_blob(
289            &mut self,
290            request: impl tonic::IntoRequest<super::PutBlobRequest>,
291        ) -> std::result::Result<
292            tonic::Response<super::PutBlobResponse>,
293            tonic::Status,
294        > {
295            self.inner
296                .ready()
297                .await
298                .map_err(|e| {
299                    tonic::Status::unknown(
300                        format!("Service was not ready: {}", e.into()),
301                    )
302                })?;
303            let codec = tonic_prost::ProstCodec::default();
304            let path = http::uri::PathAndQuery::from_static(
305                "/snix.castore.v1.BlobStoreService/PutBlob",
306            );
307            let mut req = request.into_request();
308            req.extensions_mut()
309                .insert(GrpcMethod::new("snix.castore.v1.BlobStoreService", "PutBlob"));
310            self.inner.unary(req, path, codec).await
311        }
312    }
313}
314/// Generated server implementations.
315pub mod blob_store_service_server {
316    #![allow(
317        unused_variables,
318        dead_code,
319        missing_docs,
320        clippy::wildcard_imports,
321        clippy::let_unit_value,
322    )]
323    use tonic::codegen::*;
324    /// Generated trait containing gRPC methods that should be implemented for use with BlobStoreServiceServer.
325    #[async_trait]
326    pub trait BlobStoreService: std::marker::Send + std::marker::Sync + 'static {
327        /// Stat checks if a \[BlobMeta\] for a given blob exists.
328        async fn stat_blob(
329            &self,
330            request: tonic::Request<super::StatBlobRequest>,
331        ) -> std::result::Result<
332            tonic::Response<super::StatBlobResponse>,
333            tonic::Status,
334        >;
335        /// Get retrieves a \[BlobMeta\] for a given blob digest.
336        async fn get_blob(
337            &self,
338            request: tonic::Request<super::GetBlobRequest>,
339        ) -> std::result::Result<tonic::Response<super::GetBlobResponse>, tonic::Status>;
340        /// Put persists a \[BlobMeta\] for the given blob digest.
341        async fn put_blob(
342            &self,
343            request: tonic::Request<super::PutBlobRequest>,
344        ) -> std::result::Result<tonic::Response<super::PutBlobResponse>, tonic::Status>;
345    }
346    /// BlobStoreService retrieves and stores metadata about blobs.
347    /// Blobs can consist of multiple chunks.
348    /// The stored metadata describes which chunks need to be assembled
349    /// to produce the entire blob contents.
350    /// Blobs are keyed by the BLAKE3 digest of their entire data
351    #[derive(Debug)]
352    pub struct BlobStoreServiceServer<T> {
353        inner: Arc<T>,
354        accept_compression_encodings: EnabledCompressionEncodings,
355        send_compression_encodings: EnabledCompressionEncodings,
356        max_decoding_message_size: Option<usize>,
357        max_encoding_message_size: Option<usize>,
358    }
359    impl<T> BlobStoreServiceServer<T> {
360        pub fn new(inner: T) -> Self {
361            Self::from_arc(Arc::new(inner))
362        }
363        pub fn from_arc(inner: Arc<T>) -> Self {
364            Self {
365                inner,
366                accept_compression_encodings: Default::default(),
367                send_compression_encodings: Default::default(),
368                max_decoding_message_size: None,
369                max_encoding_message_size: None,
370            }
371        }
372        pub fn with_interceptor<F>(
373            inner: T,
374            interceptor: F,
375        ) -> InterceptedService<Self, F>
376        where
377            F: tonic::service::Interceptor,
378        {
379            InterceptedService::new(Self::new(inner), interceptor)
380        }
381        /// Enable decompressing requests with the given encoding.
382        #[must_use]
383        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
384            self.accept_compression_encodings.enable(encoding);
385            self
386        }
387        /// Compress responses with the given encoding, if the client supports it.
388        #[must_use]
389        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
390            self.send_compression_encodings.enable(encoding);
391            self
392        }
393        /// Limits the maximum size of a decoded message.
394        ///
395        /// Default: `4MB`
396        #[must_use]
397        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
398            self.max_decoding_message_size = Some(limit);
399            self
400        }
401        /// Limits the maximum size of an encoded message.
402        ///
403        /// Default: `usize::MAX`
404        #[must_use]
405        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
406            self.max_encoding_message_size = Some(limit);
407            self
408        }
409    }
410    impl<T, B> tonic::codegen::Service<http::Request<B>> for BlobStoreServiceServer<T>
411    where
412        T: BlobStoreService,
413        B: Body + std::marker::Send + 'static,
414        B::Error: Into<StdError> + std::marker::Send + 'static,
415    {
416        type Response = http::Response<tonic::body::Body>;
417        type Error = std::convert::Infallible;
418        type Future = BoxFuture<Self::Response, Self::Error>;
419        fn poll_ready(
420            &mut self,
421            _cx: &mut Context<'_>,
422        ) -> Poll<std::result::Result<(), Self::Error>> {
423            Poll::Ready(Ok(()))
424        }
425        fn call(&mut self, req: http::Request<B>) -> Self::Future {
426            match req.uri().path() {
427                "/snix.castore.v1.BlobStoreService/StatBlob" => {
428                    #[allow(non_camel_case_types)]
429                    struct StatBlobSvc<T: BlobStoreService>(pub Arc<T>);
430                    impl<
431                        T: BlobStoreService,
432                    > tonic::server::UnaryService<super::StatBlobRequest>
433                    for StatBlobSvc<T> {
434                        type Response = super::StatBlobResponse;
435                        type Future = BoxFuture<
436                            tonic::Response<Self::Response>,
437                            tonic::Status,
438                        >;
439                        fn call(
440                            &mut self,
441                            request: tonic::Request<super::StatBlobRequest>,
442                        ) -> Self::Future {
443                            let inner = Arc::clone(&self.0);
444                            let fut = async move {
445                                <T as BlobStoreService>::stat_blob(&inner, request).await
446                            };
447                            Box::pin(fut)
448                        }
449                    }
450                    let accept_compression_encodings = self.accept_compression_encodings;
451                    let send_compression_encodings = self.send_compression_encodings;
452                    let max_decoding_message_size = self.max_decoding_message_size;
453                    let max_encoding_message_size = self.max_encoding_message_size;
454                    let inner = self.inner.clone();
455                    let fut = async move {
456                        let method = StatBlobSvc(inner);
457                        let codec = tonic_prost::ProstCodec::default();
458                        let mut grpc = tonic::server::Grpc::new(codec)
459                            .apply_compression_config(
460                                accept_compression_encodings,
461                                send_compression_encodings,
462                            )
463                            .apply_max_message_size_config(
464                                max_decoding_message_size,
465                                max_encoding_message_size,
466                            );
467                        let res = grpc.unary(method, req).await;
468                        Ok(res)
469                    };
470                    Box::pin(fut)
471                }
472                "/snix.castore.v1.BlobStoreService/GetBlob" => {
473                    #[allow(non_camel_case_types)]
474                    struct GetBlobSvc<T: BlobStoreService>(pub Arc<T>);
475                    impl<
476                        T: BlobStoreService,
477                    > tonic::server::UnaryService<super::GetBlobRequest>
478                    for GetBlobSvc<T> {
479                        type Response = super::GetBlobResponse;
480                        type Future = BoxFuture<
481                            tonic::Response<Self::Response>,
482                            tonic::Status,
483                        >;
484                        fn call(
485                            &mut self,
486                            request: tonic::Request<super::GetBlobRequest>,
487                        ) -> Self::Future {
488                            let inner = Arc::clone(&self.0);
489                            let fut = async move {
490                                <T as BlobStoreService>::get_blob(&inner, request).await
491                            };
492                            Box::pin(fut)
493                        }
494                    }
495                    let accept_compression_encodings = self.accept_compression_encodings;
496                    let send_compression_encodings = self.send_compression_encodings;
497                    let max_decoding_message_size = self.max_decoding_message_size;
498                    let max_encoding_message_size = self.max_encoding_message_size;
499                    let inner = self.inner.clone();
500                    let fut = async move {
501                        let method = GetBlobSvc(inner);
502                        let codec = tonic_prost::ProstCodec::default();
503                        let mut grpc = tonic::server::Grpc::new(codec)
504                            .apply_compression_config(
505                                accept_compression_encodings,
506                                send_compression_encodings,
507                            )
508                            .apply_max_message_size_config(
509                                max_decoding_message_size,
510                                max_encoding_message_size,
511                            );
512                        let res = grpc.unary(method, req).await;
513                        Ok(res)
514                    };
515                    Box::pin(fut)
516                }
517                "/snix.castore.v1.BlobStoreService/PutBlob" => {
518                    #[allow(non_camel_case_types)]
519                    struct PutBlobSvc<T: BlobStoreService>(pub Arc<T>);
520                    impl<
521                        T: BlobStoreService,
522                    > tonic::server::UnaryService<super::PutBlobRequest>
523                    for PutBlobSvc<T> {
524                        type Response = super::PutBlobResponse;
525                        type Future = BoxFuture<
526                            tonic::Response<Self::Response>,
527                            tonic::Status,
528                        >;
529                        fn call(
530                            &mut self,
531                            request: tonic::Request<super::PutBlobRequest>,
532                        ) -> Self::Future {
533                            let inner = Arc::clone(&self.0);
534                            let fut = async move {
535                                <T as BlobStoreService>::put_blob(&inner, request).await
536                            };
537                            Box::pin(fut)
538                        }
539                    }
540                    let accept_compression_encodings = self.accept_compression_encodings;
541                    let send_compression_encodings = self.send_compression_encodings;
542                    let max_decoding_message_size = self.max_decoding_message_size;
543                    let max_encoding_message_size = self.max_encoding_message_size;
544                    let inner = self.inner.clone();
545                    let fut = async move {
546                        let method = PutBlobSvc(inner);
547                        let codec = tonic_prost::ProstCodec::default();
548                        let mut grpc = tonic::server::Grpc::new(codec)
549                            .apply_compression_config(
550                                accept_compression_encodings,
551                                send_compression_encodings,
552                            )
553                            .apply_max_message_size_config(
554                                max_decoding_message_size,
555                                max_encoding_message_size,
556                            );
557                        let res = grpc.unary(method, req).await;
558                        Ok(res)
559                    };
560                    Box::pin(fut)
561                }
562                _ => {
563                    Box::pin(async move {
564                        let mut response = http::Response::new(
565                            tonic::body::Body::default(),
566                        );
567                        let headers = response.headers_mut();
568                        headers
569                            .insert(
570                                tonic::Status::GRPC_STATUS,
571                                (tonic::Code::Unimplemented as i32).into(),
572                            );
573                        headers
574                            .insert(
575                                http::header::CONTENT_TYPE,
576                                tonic::metadata::GRPC_CONTENT_TYPE,
577                            );
578                        Ok(response)
579                    })
580                }
581            }
582        }
583    }
584    impl<T> Clone for BlobStoreServiceServer<T> {
585        fn clone(&self) -> Self {
586            let inner = self.inner.clone();
587            Self {
588                inner,
589                accept_compression_encodings: self.accept_compression_encodings,
590                send_compression_encodings: self.send_compression_encodings,
591                max_decoding_message_size: self.max_decoding_message_size,
592                max_encoding_message_size: self.max_encoding_message_size,
593            }
594        }
595    }
596    /// Generated gRPC service name
597    pub const SERVICE_NAME: &str = "snix.castore.v1.BlobStoreService";
598    impl<T> tonic::server::NamedService for BlobStoreServiceServer<T> {
599        const NAME: &'static str = SERVICE_NAME;
600    }
601}
602#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
603pub struct StatChunkRequest {
604    /// The blake3 digest of the chunk requested
605    #[prost(bytes = "bytes", tag = "1")]
606    pub digest: ::prost::bytes::Bytes,
607}
608#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
609pub struct StatChunkResponse {}
610#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
611pub struct GetChunkRequest {
612    /// The blake3 digest of the chunk requested
613    #[prost(bytes = "bytes", tag = "1")]
614    pub digest: ::prost::bytes::Bytes,
615}
616#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
617pub struct GetChunkResponse {
618    /// Raw chunk payload
619    #[prost(bytes = "bytes", tag = "1")]
620    pub data: ::prost::bytes::Bytes,
621}
622#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
623pub struct PutChunkRequest {
624    /// Raw chunk payload
625    #[prost(bytes = "bytes", tag = "1")]
626    pub data: ::prost::bytes::Bytes,
627}
628#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
629pub struct PutChunkResponse {
630    /// The blake3 digest of the chunk received
631    #[prost(bytes = "bytes", tag = "1")]
632    pub digest: ::prost::bytes::Bytes,
633}
634/// Generated client implementations.
635pub mod chunk_store_service_client {
636    #![allow(
637        unused_variables,
638        dead_code,
639        missing_docs,
640        clippy::wildcard_imports,
641        clippy::let_unit_value,
642    )]
643    use tonic::codegen::*;
644    use tonic::codegen::http::Uri;
645    /// ChunkStoreService allows reading (or uploading) content-addressed chunks of raw data.
646    /// BLAKE3 is used as a hashing function for the data. Uploading a blob will
647    /// return the BLAKE3 digest of it, and that's the identifier used to Read/Stat
648    /// them too.
649    /// Chunks are considered small enough to not require any further chunking,
650    /// but may be broken down into smaller messages when sent as proto messages,
651    /// due to message size restrictions.
652    #[derive(Debug, Clone)]
653    pub struct ChunkStoreServiceClient<T> {
654        inner: tonic::client::Grpc<T>,
655    }
656    impl ChunkStoreServiceClient<tonic::transport::Channel> {
657        /// Attempt to create a new client by connecting to a given endpoint.
658        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
659        where
660            D: TryInto<tonic::transport::Endpoint>,
661            D::Error: Into<StdError>,
662        {
663            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
664            Ok(Self::new(conn))
665        }
666    }
667    impl<T> ChunkStoreServiceClient<T>
668    where
669        T: tonic::client::GrpcService<tonic::body::Body>,
670        T::Error: Into<StdError>,
671        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
672        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
673    {
674        pub fn new(inner: T) -> Self {
675            let inner = tonic::client::Grpc::new(inner);
676            Self { inner }
677        }
678        pub fn with_origin(inner: T, origin: Uri) -> Self {
679            let inner = tonic::client::Grpc::with_origin(inner, origin);
680            Self { inner }
681        }
682        pub fn with_interceptor<F>(
683            inner: T,
684            interceptor: F,
685        ) -> ChunkStoreServiceClient<InterceptedService<T, F>>
686        where
687            F: tonic::service::Interceptor,
688            T::ResponseBody: Default,
689            T: tonic::codegen::Service<
690                http::Request<tonic::body::Body>,
691                Response = http::Response<
692                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
693                >,
694            >,
695            <T as tonic::codegen::Service<
696                http::Request<tonic::body::Body>,
697            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
698        {
699            ChunkStoreServiceClient::new(InterceptedService::new(inner, interceptor))
700        }
701        /// Compress requests with the given encoding.
702        ///
703        /// This requires the server to support it otherwise it might respond with an
704        /// error.
705        #[must_use]
706        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
707            self.inner = self.inner.send_compressed(encoding);
708            self
709        }
710        /// Enable decompressing responses.
711        #[must_use]
712        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
713            self.inner = self.inner.accept_compressed(encoding);
714            self
715        }
716        /// Limits the maximum size of a decoded message.
717        ///
718        /// Default: `4MB`
719        #[must_use]
720        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
721            self.inner = self.inner.max_decoding_message_size(limit);
722            self
723        }
724        /// Limits the maximum size of an encoded message.
725        ///
726        /// Default: `usize::MAX`
727        #[must_use]
728        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
729            self.inner = self.inner.max_encoding_message_size(limit);
730            self
731        }
732        /// Stat can be used to check for the existence of a chunk.
733        pub async fn stat_chunk(
734            &mut self,
735            request: impl tonic::IntoRequest<super::StatChunkRequest>,
736        ) -> std::result::Result<
737            tonic::Response<super::StatChunkResponse>,
738            tonic::Status,
739        > {
740            self.inner
741                .ready()
742                .await
743                .map_err(|e| {
744                    tonic::Status::unknown(
745                        format!("Service was not ready: {}", e.into()),
746                    )
747                })?;
748            let codec = tonic_prost::ProstCodec::default();
749            let path = http::uri::PathAndQuery::from_static(
750                "/snix.castore.v1.ChunkStoreService/StatChunk",
751            );
752            let mut req = request.into_request();
753            req.extensions_mut()
754                .insert(
755                    GrpcMethod::new("snix.castore.v1.ChunkStoreService", "StatChunk"),
756                );
757            self.inner.unary(req, path, codec).await
758        }
759        /// Get can be used to retrieve a chunk.
760        /// The server may break down the response into a stream of smaller messages,
761        /// to keep proto messages smaller than its maximum chunk size.
762        pub async fn get_chunk(
763            &mut self,
764            request: impl tonic::IntoRequest<super::GetChunkRequest>,
765        ) -> std::result::Result<
766            tonic::Response<tonic::codec::Streaming<super::GetChunkResponse>>,
767            tonic::Status,
768        > {
769            self.inner
770                .ready()
771                .await
772                .map_err(|e| {
773                    tonic::Status::unknown(
774                        format!("Service was not ready: {}", e.into()),
775                    )
776                })?;
777            let codec = tonic_prost::ProstCodec::default();
778            let path = http::uri::PathAndQuery::from_static(
779                "/snix.castore.v1.ChunkStoreService/GetChunk",
780            );
781            let mut req = request.into_request();
782            req.extensions_mut()
783                .insert(
784                    GrpcMethod::new("snix.castore.v1.ChunkStoreService", "GetChunk"),
785                );
786            self.inner.server_streaming(req, path, codec).await
787        }
788        /// PutChunk can be used to upload a chunk.
789        /// The client may break down the response into a stream of smaller messages,
790        /// to keep proto messages smaller than its maximum chunk size.
791        pub async fn put_chunk(
792            &mut self,
793            request: impl tonic::IntoStreamingRequest<Message = super::PutChunkRequest>,
794        ) -> std::result::Result<
795            tonic::Response<super::PutChunkResponse>,
796            tonic::Status,
797        > {
798            self.inner
799                .ready()
800                .await
801                .map_err(|e| {
802                    tonic::Status::unknown(
803                        format!("Service was not ready: {}", e.into()),
804                    )
805                })?;
806            let codec = tonic_prost::ProstCodec::default();
807            let path = http::uri::PathAndQuery::from_static(
808                "/snix.castore.v1.ChunkStoreService/PutChunk",
809            );
810            let mut req = request.into_streaming_request();
811            req.extensions_mut()
812                .insert(
813                    GrpcMethod::new("snix.castore.v1.ChunkStoreService", "PutChunk"),
814                );
815            self.inner.client_streaming(req, path, codec).await
816        }
817    }
818}
819/// Generated server implementations.
820pub mod chunk_store_service_server {
821    #![allow(
822        unused_variables,
823        dead_code,
824        missing_docs,
825        clippy::wildcard_imports,
826        clippy::let_unit_value,
827    )]
828    use tonic::codegen::*;
829    /// Generated trait containing gRPC methods that should be implemented for use with ChunkStoreServiceServer.
830    #[async_trait]
831    pub trait ChunkStoreService: std::marker::Send + std::marker::Sync + 'static {
832        /// Stat can be used to check for the existence of a chunk.
833        async fn stat_chunk(
834            &self,
835            request: tonic::Request<super::StatChunkRequest>,
836        ) -> std::result::Result<
837            tonic::Response<super::StatChunkResponse>,
838            tonic::Status,
839        >;
840        /// Server streaming response type for the GetChunk method.
841        type GetChunkStream: tonic::codegen::tokio_stream::Stream<
842                Item = std::result::Result<super::GetChunkResponse, tonic::Status>,
843            >
844            + std::marker::Send
845            + 'static;
846        /// Get can be used to retrieve a chunk.
847        /// The server may break down the response into a stream of smaller messages,
848        /// to keep proto messages smaller than its maximum chunk size.
849        async fn get_chunk(
850            &self,
851            request: tonic::Request<super::GetChunkRequest>,
852        ) -> std::result::Result<tonic::Response<Self::GetChunkStream>, tonic::Status>;
853        /// PutChunk can be used to upload a chunk.
854        /// The client may break down the response into a stream of smaller messages,
855        /// to keep proto messages smaller than its maximum chunk size.
856        async fn put_chunk(
857            &self,
858            request: tonic::Request<tonic::Streaming<super::PutChunkRequest>>,
859        ) -> std::result::Result<
860            tonic::Response<super::PutChunkResponse>,
861            tonic::Status,
862        >;
863    }
864    /// ChunkStoreService allows reading (or uploading) content-addressed chunks of raw data.
865    /// BLAKE3 is used as a hashing function for the data. Uploading a blob will
866    /// return the BLAKE3 digest of it, and that's the identifier used to Read/Stat
867    /// them too.
868    /// Chunks are considered small enough to not require any further chunking,
869    /// but may be broken down into smaller messages when sent as proto messages,
870    /// due to message size restrictions.
871    #[derive(Debug)]
872    pub struct ChunkStoreServiceServer<T> {
873        inner: Arc<T>,
874        accept_compression_encodings: EnabledCompressionEncodings,
875        send_compression_encodings: EnabledCompressionEncodings,
876        max_decoding_message_size: Option<usize>,
877        max_encoding_message_size: Option<usize>,
878    }
879    impl<T> ChunkStoreServiceServer<T> {
880        pub fn new(inner: T) -> Self {
881            Self::from_arc(Arc::new(inner))
882        }
883        pub fn from_arc(inner: Arc<T>) -> Self {
884            Self {
885                inner,
886                accept_compression_encodings: Default::default(),
887                send_compression_encodings: Default::default(),
888                max_decoding_message_size: None,
889                max_encoding_message_size: None,
890            }
891        }
892        pub fn with_interceptor<F>(
893            inner: T,
894            interceptor: F,
895        ) -> InterceptedService<Self, F>
896        where
897            F: tonic::service::Interceptor,
898        {
899            InterceptedService::new(Self::new(inner), interceptor)
900        }
901        /// Enable decompressing requests with the given encoding.
902        #[must_use]
903        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
904            self.accept_compression_encodings.enable(encoding);
905            self
906        }
907        /// Compress responses with the given encoding, if the client supports it.
908        #[must_use]
909        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
910            self.send_compression_encodings.enable(encoding);
911            self
912        }
913        /// Limits the maximum size of a decoded message.
914        ///
915        /// Default: `4MB`
916        #[must_use]
917        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
918            self.max_decoding_message_size = Some(limit);
919            self
920        }
921        /// Limits the maximum size of an encoded message.
922        ///
923        /// Default: `usize::MAX`
924        #[must_use]
925        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
926            self.max_encoding_message_size = Some(limit);
927            self
928        }
929    }
930    impl<T, B> tonic::codegen::Service<http::Request<B>> for ChunkStoreServiceServer<T>
931    where
932        T: ChunkStoreService,
933        B: Body + std::marker::Send + 'static,
934        B::Error: Into<StdError> + std::marker::Send + 'static,
935    {
936        type Response = http::Response<tonic::body::Body>;
937        type Error = std::convert::Infallible;
938        type Future = BoxFuture<Self::Response, Self::Error>;
939        fn poll_ready(
940            &mut self,
941            _cx: &mut Context<'_>,
942        ) -> Poll<std::result::Result<(), Self::Error>> {
943            Poll::Ready(Ok(()))
944        }
945        fn call(&mut self, req: http::Request<B>) -> Self::Future {
946            match req.uri().path() {
947                "/snix.castore.v1.ChunkStoreService/StatChunk" => {
948                    #[allow(non_camel_case_types)]
949                    struct StatChunkSvc<T: ChunkStoreService>(pub Arc<T>);
950                    impl<
951                        T: ChunkStoreService,
952                    > tonic::server::UnaryService<super::StatChunkRequest>
953                    for StatChunkSvc<T> {
954                        type Response = super::StatChunkResponse;
955                        type Future = BoxFuture<
956                            tonic::Response<Self::Response>,
957                            tonic::Status,
958                        >;
959                        fn call(
960                            &mut self,
961                            request: tonic::Request<super::StatChunkRequest>,
962                        ) -> Self::Future {
963                            let inner = Arc::clone(&self.0);
964                            let fut = async move {
965                                <T as ChunkStoreService>::stat_chunk(&inner, request).await
966                            };
967                            Box::pin(fut)
968                        }
969                    }
970                    let accept_compression_encodings = self.accept_compression_encodings;
971                    let send_compression_encodings = self.send_compression_encodings;
972                    let max_decoding_message_size = self.max_decoding_message_size;
973                    let max_encoding_message_size = self.max_encoding_message_size;
974                    let inner = self.inner.clone();
975                    let fut = async move {
976                        let method = StatChunkSvc(inner);
977                        let codec = tonic_prost::ProstCodec::default();
978                        let mut grpc = tonic::server::Grpc::new(codec)
979                            .apply_compression_config(
980                                accept_compression_encodings,
981                                send_compression_encodings,
982                            )
983                            .apply_max_message_size_config(
984                                max_decoding_message_size,
985                                max_encoding_message_size,
986                            );
987                        let res = grpc.unary(method, req).await;
988                        Ok(res)
989                    };
990                    Box::pin(fut)
991                }
992                "/snix.castore.v1.ChunkStoreService/GetChunk" => {
993                    #[allow(non_camel_case_types)]
994                    struct GetChunkSvc<T: ChunkStoreService>(pub Arc<T>);
995                    impl<
996                        T: ChunkStoreService,
997                    > tonic::server::ServerStreamingService<super::GetChunkRequest>
998                    for GetChunkSvc<T> {
999                        type Response = super::GetChunkResponse;
1000                        type ResponseStream = T::GetChunkStream;
1001                        type Future = BoxFuture<
1002                            tonic::Response<Self::ResponseStream>,
1003                            tonic::Status,
1004                        >;
1005                        fn call(
1006                            &mut self,
1007                            request: tonic::Request<super::GetChunkRequest>,
1008                        ) -> Self::Future {
1009                            let inner = Arc::clone(&self.0);
1010                            let fut = async move {
1011                                <T as ChunkStoreService>::get_chunk(&inner, request).await
1012                            };
1013                            Box::pin(fut)
1014                        }
1015                    }
1016                    let accept_compression_encodings = self.accept_compression_encodings;
1017                    let send_compression_encodings = self.send_compression_encodings;
1018                    let max_decoding_message_size = self.max_decoding_message_size;
1019                    let max_encoding_message_size = self.max_encoding_message_size;
1020                    let inner = self.inner.clone();
1021                    let fut = async move {
1022                        let method = GetChunkSvc(inner);
1023                        let codec = tonic_prost::ProstCodec::default();
1024                        let mut grpc = tonic::server::Grpc::new(codec)
1025                            .apply_compression_config(
1026                                accept_compression_encodings,
1027                                send_compression_encodings,
1028                            )
1029                            .apply_max_message_size_config(
1030                                max_decoding_message_size,
1031                                max_encoding_message_size,
1032                            );
1033                        let res = grpc.server_streaming(method, req).await;
1034                        Ok(res)
1035                    };
1036                    Box::pin(fut)
1037                }
1038                "/snix.castore.v1.ChunkStoreService/PutChunk" => {
1039                    #[allow(non_camel_case_types)]
1040                    struct PutChunkSvc<T: ChunkStoreService>(pub Arc<T>);
1041                    impl<
1042                        T: ChunkStoreService,
1043                    > tonic::server::ClientStreamingService<super::PutChunkRequest>
1044                    for PutChunkSvc<T> {
1045                        type Response = super::PutChunkResponse;
1046                        type Future = BoxFuture<
1047                            tonic::Response<Self::Response>,
1048                            tonic::Status,
1049                        >;
1050                        fn call(
1051                            &mut self,
1052                            request: tonic::Request<
1053                                tonic::Streaming<super::PutChunkRequest>,
1054                            >,
1055                        ) -> Self::Future {
1056                            let inner = Arc::clone(&self.0);
1057                            let fut = async move {
1058                                <T as ChunkStoreService>::put_chunk(&inner, request).await
1059                            };
1060                            Box::pin(fut)
1061                        }
1062                    }
1063                    let accept_compression_encodings = self.accept_compression_encodings;
1064                    let send_compression_encodings = self.send_compression_encodings;
1065                    let max_decoding_message_size = self.max_decoding_message_size;
1066                    let max_encoding_message_size = self.max_encoding_message_size;
1067                    let inner = self.inner.clone();
1068                    let fut = async move {
1069                        let method = PutChunkSvc(inner);
1070                        let codec = tonic_prost::ProstCodec::default();
1071                        let mut grpc = tonic::server::Grpc::new(codec)
1072                            .apply_compression_config(
1073                                accept_compression_encodings,
1074                                send_compression_encodings,
1075                            )
1076                            .apply_max_message_size_config(
1077                                max_decoding_message_size,
1078                                max_encoding_message_size,
1079                            );
1080                        let res = grpc.client_streaming(method, req).await;
1081                        Ok(res)
1082                    };
1083                    Box::pin(fut)
1084                }
1085                _ => {
1086                    Box::pin(async move {
1087                        let mut response = http::Response::new(
1088                            tonic::body::Body::default(),
1089                        );
1090                        let headers = response.headers_mut();
1091                        headers
1092                            .insert(
1093                                tonic::Status::GRPC_STATUS,
1094                                (tonic::Code::Unimplemented as i32).into(),
1095                            );
1096                        headers
1097                            .insert(
1098                                http::header::CONTENT_TYPE,
1099                                tonic::metadata::GRPC_CONTENT_TYPE,
1100                            );
1101                        Ok(response)
1102                    })
1103                }
1104            }
1105        }
1106    }
1107    impl<T> Clone for ChunkStoreServiceServer<T> {
1108        fn clone(&self) -> Self {
1109            let inner = self.inner.clone();
1110            Self {
1111                inner,
1112                accept_compression_encodings: self.accept_compression_encodings,
1113                send_compression_encodings: self.send_compression_encodings,
1114                max_decoding_message_size: self.max_decoding_message_size,
1115                max_encoding_message_size: self.max_encoding_message_size,
1116            }
1117        }
1118    }
1119    /// Generated gRPC service name
1120    pub const SERVICE_NAME: &str = "snix.castore.v1.ChunkStoreService";
1121    impl<T> tonic::server::NamedService for ChunkStoreServiceServer<T> {
1122        const NAME: &'static str = SERVICE_NAME;
1123    }
1124}
1125#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1126pub struct GetDirectoryRequest {
1127    /// If set to true, recursively resolve all child Directory messages.
1128    /// Directory messages SHOULD be streamed in a recursive breadth-first walk,
1129    /// but other orders are also fine, as long as Directory messages are only
1130    /// sent after they are referred to from previously sent Directory messages.
1131    #[prost(bool, tag = "2")]
1132    pub recursive: bool,
1133    #[prost(oneof = "get_directory_request::ByWhat", tags = "1")]
1134    pub by_what: ::core::option::Option<get_directory_request::ByWhat>,
1135}
1136/// Nested message and enum types in `GetDirectoryRequest`.
1137pub mod get_directory_request {
1138    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
1139    pub enum ByWhat {
1140        /// The blake3 hash of the (root) Directory message, serialized in
1141        /// protobuf canonical form.
1142        /// Keep in mind this can be a subtree of another root.
1143        #[prost(bytes, tag = "1")]
1144        Digest(::prost::bytes::Bytes),
1145    }
1146}
1147#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
1148pub struct PutDirectoryResponse {
1149    #[prost(bytes = "bytes", tag = "1")]
1150    pub root_digest: ::prost::bytes::Bytes,
1151}
1152/// Generated client implementations.
1153pub mod directory_service_client {
1154    #![allow(
1155        unused_variables,
1156        dead_code,
1157        missing_docs,
1158        clippy::wildcard_imports,
1159        clippy::let_unit_value,
1160    )]
1161    use tonic::codegen::*;
1162    use tonic::codegen::http::Uri;
1163    #[derive(Debug, Clone)]
1164    pub struct DirectoryServiceClient<T> {
1165        inner: tonic::client::Grpc<T>,
1166    }
1167    impl DirectoryServiceClient<tonic::transport::Channel> {
1168        /// Attempt to create a new client by connecting to a given endpoint.
1169        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
1170        where
1171            D: TryInto<tonic::transport::Endpoint>,
1172            D::Error: Into<StdError>,
1173        {
1174            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
1175            Ok(Self::new(conn))
1176        }
1177    }
1178    impl<T> DirectoryServiceClient<T>
1179    where
1180        T: tonic::client::GrpcService<tonic::body::Body>,
1181        T::Error: Into<StdError>,
1182        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
1183        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
1184    {
1185        pub fn new(inner: T) -> Self {
1186            let inner = tonic::client::Grpc::new(inner);
1187            Self { inner }
1188        }
1189        pub fn with_origin(inner: T, origin: Uri) -> Self {
1190            let inner = tonic::client::Grpc::with_origin(inner, origin);
1191            Self { inner }
1192        }
1193        pub fn with_interceptor<F>(
1194            inner: T,
1195            interceptor: F,
1196        ) -> DirectoryServiceClient<InterceptedService<T, F>>
1197        where
1198            F: tonic::service::Interceptor,
1199            T::ResponseBody: Default,
1200            T: tonic::codegen::Service<
1201                http::Request<tonic::body::Body>,
1202                Response = http::Response<
1203                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
1204                >,
1205            >,
1206            <T as tonic::codegen::Service<
1207                http::Request<tonic::body::Body>,
1208            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
1209        {
1210            DirectoryServiceClient::new(InterceptedService::new(inner, interceptor))
1211        }
1212        /// Compress requests with the given encoding.
1213        ///
1214        /// This requires the server to support it otherwise it might respond with an
1215        /// error.
1216        #[must_use]
1217        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
1218            self.inner = self.inner.send_compressed(encoding);
1219            self
1220        }
1221        /// Enable decompressing responses.
1222        #[must_use]
1223        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
1224            self.inner = self.inner.accept_compressed(encoding);
1225            self
1226        }
1227        /// Limits the maximum size of a decoded message.
1228        ///
1229        /// Default: `4MB`
1230        #[must_use]
1231        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
1232            self.inner = self.inner.max_decoding_message_size(limit);
1233            self
1234        }
1235        /// Limits the maximum size of an encoded message.
1236        ///
1237        /// Default: `usize::MAX`
1238        #[must_use]
1239        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
1240            self.inner = self.inner.max_encoding_message_size(limit);
1241            self
1242        }
1243        /// Get retrieves a stream of Directory messages, by using the lookup
1244        /// parameters in GetDirectoryRequest.
1245        /// Keep in mind multiple DirectoryNodes in different parts of the graph might
1246        /// have the same digest if they have the same underlying contents,
1247        /// so sending subsequent ones can be omitted.
1248        ///
1249        /// It is okay for certain implementations to only allow retrieval of
1250        /// Directory digests that are at the "root", aka the last element that's
1251        /// sent in a Put. This makes sense for implementations bundling closures of
1252        /// directories together in batches.
1253        pub async fn get(
1254            &mut self,
1255            request: impl tonic::IntoRequest<super::GetDirectoryRequest>,
1256        ) -> std::result::Result<
1257            tonic::Response<tonic::codec::Streaming<super::Directory>>,
1258            tonic::Status,
1259        > {
1260            self.inner
1261                .ready()
1262                .await
1263                .map_err(|e| {
1264                    tonic::Status::unknown(
1265                        format!("Service was not ready: {}", e.into()),
1266                    )
1267                })?;
1268            let codec = tonic_prost::ProstCodec::default();
1269            let path = http::uri::PathAndQuery::from_static(
1270                "/snix.castore.v1.DirectoryService/Get",
1271            );
1272            let mut req = request.into_request();
1273            req.extensions_mut()
1274                .insert(GrpcMethod::new("snix.castore.v1.DirectoryService", "Get"));
1275            self.inner.server_streaming(req, path, codec).await
1276        }
1277        /// Put uploads a graph of Directory messages.
1278        /// Individual Directory messages need to be send in an order walking up
1279        /// from the leaves to the root - a Directory message can only refer to
1280        /// Directory messages previously sent in the same stream.
1281        /// Keep in mind multiple DirectoryNodes in different parts of the graph might
1282        /// have the same digest if they have the same underlying contents,
1283        /// so sending subsequent ones can be omitted.
1284        /// We might add a separate method, allowing to send partial graphs at a later
1285        /// time, if requiring to send the full graph turns out to be a problem.
1286        pub async fn put(
1287            &mut self,
1288            request: impl tonic::IntoStreamingRequest<Message = super::Directory>,
1289        ) -> std::result::Result<
1290            tonic::Response<super::PutDirectoryResponse>,
1291            tonic::Status,
1292        > {
1293            self.inner
1294                .ready()
1295                .await
1296                .map_err(|e| {
1297                    tonic::Status::unknown(
1298                        format!("Service was not ready: {}", e.into()),
1299                    )
1300                })?;
1301            let codec = tonic_prost::ProstCodec::default();
1302            let path = http::uri::PathAndQuery::from_static(
1303                "/snix.castore.v1.DirectoryService/Put",
1304            );
1305            let mut req = request.into_streaming_request();
1306            req.extensions_mut()
1307                .insert(GrpcMethod::new("snix.castore.v1.DirectoryService", "Put"));
1308            self.inner.client_streaming(req, path, codec).await
1309        }
1310    }
1311}
1312/// Generated server implementations.
1313pub mod directory_service_server {
1314    #![allow(
1315        unused_variables,
1316        dead_code,
1317        missing_docs,
1318        clippy::wildcard_imports,
1319        clippy::let_unit_value,
1320    )]
1321    use tonic::codegen::*;
1322    /// Generated trait containing gRPC methods that should be implemented for use with DirectoryServiceServer.
1323    #[async_trait]
1324    pub trait DirectoryService: std::marker::Send + std::marker::Sync + 'static {
1325        /// Server streaming response type for the Get method.
1326        type GetStream: tonic::codegen::tokio_stream::Stream<
1327                Item = std::result::Result<super::Directory, tonic::Status>,
1328            >
1329            + std::marker::Send
1330            + 'static;
1331        /// Get retrieves a stream of Directory messages, by using the lookup
1332        /// parameters in GetDirectoryRequest.
1333        /// Keep in mind multiple DirectoryNodes in different parts of the graph might
1334        /// have the same digest if they have the same underlying contents,
1335        /// so sending subsequent ones can be omitted.
1336        ///
1337        /// It is okay for certain implementations to only allow retrieval of
1338        /// Directory digests that are at the "root", aka the last element that's
1339        /// sent in a Put. This makes sense for implementations bundling closures of
1340        /// directories together in batches.
1341        async fn get(
1342            &self,
1343            request: tonic::Request<super::GetDirectoryRequest>,
1344        ) -> std::result::Result<tonic::Response<Self::GetStream>, tonic::Status>;
1345        /// Put uploads a graph of Directory messages.
1346        /// Individual Directory messages need to be send in an order walking up
1347        /// from the leaves to the root - a Directory message can only refer to
1348        /// Directory messages previously sent in the same stream.
1349        /// Keep in mind multiple DirectoryNodes in different parts of the graph might
1350        /// have the same digest if they have the same underlying contents,
1351        /// so sending subsequent ones can be omitted.
1352        /// We might add a separate method, allowing to send partial graphs at a later
1353        /// time, if requiring to send the full graph turns out to be a problem.
1354        async fn put(
1355            &self,
1356            request: tonic::Request<tonic::Streaming<super::Directory>>,
1357        ) -> std::result::Result<
1358            tonic::Response<super::PutDirectoryResponse>,
1359            tonic::Status,
1360        >;
1361    }
1362    #[derive(Debug)]
1363    pub struct DirectoryServiceServer<T> {
1364        inner: Arc<T>,
1365        accept_compression_encodings: EnabledCompressionEncodings,
1366        send_compression_encodings: EnabledCompressionEncodings,
1367        max_decoding_message_size: Option<usize>,
1368        max_encoding_message_size: Option<usize>,
1369    }
1370    impl<T> DirectoryServiceServer<T> {
1371        pub fn new(inner: T) -> Self {
1372            Self::from_arc(Arc::new(inner))
1373        }
1374        pub fn from_arc(inner: Arc<T>) -> Self {
1375            Self {
1376                inner,
1377                accept_compression_encodings: Default::default(),
1378                send_compression_encodings: Default::default(),
1379                max_decoding_message_size: None,
1380                max_encoding_message_size: None,
1381            }
1382        }
1383        pub fn with_interceptor<F>(
1384            inner: T,
1385            interceptor: F,
1386        ) -> InterceptedService<Self, F>
1387        where
1388            F: tonic::service::Interceptor,
1389        {
1390            InterceptedService::new(Self::new(inner), interceptor)
1391        }
1392        /// Enable decompressing requests with the given encoding.
1393        #[must_use]
1394        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
1395            self.accept_compression_encodings.enable(encoding);
1396            self
1397        }
1398        /// Compress responses with the given encoding, if the client supports it.
1399        #[must_use]
1400        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
1401            self.send_compression_encodings.enable(encoding);
1402            self
1403        }
1404        /// Limits the maximum size of a decoded message.
1405        ///
1406        /// Default: `4MB`
1407        #[must_use]
1408        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
1409            self.max_decoding_message_size = Some(limit);
1410            self
1411        }
1412        /// Limits the maximum size of an encoded message.
1413        ///
1414        /// Default: `usize::MAX`
1415        #[must_use]
1416        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
1417            self.max_encoding_message_size = Some(limit);
1418            self
1419        }
1420    }
1421    impl<T, B> tonic::codegen::Service<http::Request<B>> for DirectoryServiceServer<T>
1422    where
1423        T: DirectoryService,
1424        B: Body + std::marker::Send + 'static,
1425        B::Error: Into<StdError> + std::marker::Send + 'static,
1426    {
1427        type Response = http::Response<tonic::body::Body>;
1428        type Error = std::convert::Infallible;
1429        type Future = BoxFuture<Self::Response, Self::Error>;
1430        fn poll_ready(
1431            &mut self,
1432            _cx: &mut Context<'_>,
1433        ) -> Poll<std::result::Result<(), Self::Error>> {
1434            Poll::Ready(Ok(()))
1435        }
1436        fn call(&mut self, req: http::Request<B>) -> Self::Future {
1437            match req.uri().path() {
1438                "/snix.castore.v1.DirectoryService/Get" => {
1439                    #[allow(non_camel_case_types)]
1440                    struct GetSvc<T: DirectoryService>(pub Arc<T>);
1441                    impl<
1442                        T: DirectoryService,
1443                    > tonic::server::ServerStreamingService<super::GetDirectoryRequest>
1444                    for GetSvc<T> {
1445                        type Response = super::Directory;
1446                        type ResponseStream = T::GetStream;
1447                        type Future = BoxFuture<
1448                            tonic::Response<Self::ResponseStream>,
1449                            tonic::Status,
1450                        >;
1451                        fn call(
1452                            &mut self,
1453                            request: tonic::Request<super::GetDirectoryRequest>,
1454                        ) -> Self::Future {
1455                            let inner = Arc::clone(&self.0);
1456                            let fut = async move {
1457                                <T as DirectoryService>::get(&inner, request).await
1458                            };
1459                            Box::pin(fut)
1460                        }
1461                    }
1462                    let accept_compression_encodings = self.accept_compression_encodings;
1463                    let send_compression_encodings = self.send_compression_encodings;
1464                    let max_decoding_message_size = self.max_decoding_message_size;
1465                    let max_encoding_message_size = self.max_encoding_message_size;
1466                    let inner = self.inner.clone();
1467                    let fut = async move {
1468                        let method = GetSvc(inner);
1469                        let codec = tonic_prost::ProstCodec::default();
1470                        let mut grpc = tonic::server::Grpc::new(codec)
1471                            .apply_compression_config(
1472                                accept_compression_encodings,
1473                                send_compression_encodings,
1474                            )
1475                            .apply_max_message_size_config(
1476                                max_decoding_message_size,
1477                                max_encoding_message_size,
1478                            );
1479                        let res = grpc.server_streaming(method, req).await;
1480                        Ok(res)
1481                    };
1482                    Box::pin(fut)
1483                }
1484                "/snix.castore.v1.DirectoryService/Put" => {
1485                    #[allow(non_camel_case_types)]
1486                    struct PutSvc<T: DirectoryService>(pub Arc<T>);
1487                    impl<
1488                        T: DirectoryService,
1489                    > tonic::server::ClientStreamingService<super::Directory>
1490                    for PutSvc<T> {
1491                        type Response = super::PutDirectoryResponse;
1492                        type Future = BoxFuture<
1493                            tonic::Response<Self::Response>,
1494                            tonic::Status,
1495                        >;
1496                        fn call(
1497                            &mut self,
1498                            request: tonic::Request<tonic::Streaming<super::Directory>>,
1499                        ) -> Self::Future {
1500                            let inner = Arc::clone(&self.0);
1501                            let fut = async move {
1502                                <T as DirectoryService>::put(&inner, request).await
1503                            };
1504                            Box::pin(fut)
1505                        }
1506                    }
1507                    let accept_compression_encodings = self.accept_compression_encodings;
1508                    let send_compression_encodings = self.send_compression_encodings;
1509                    let max_decoding_message_size = self.max_decoding_message_size;
1510                    let max_encoding_message_size = self.max_encoding_message_size;
1511                    let inner = self.inner.clone();
1512                    let fut = async move {
1513                        let method = PutSvc(inner);
1514                        let codec = tonic_prost::ProstCodec::default();
1515                        let mut grpc = tonic::server::Grpc::new(codec)
1516                            .apply_compression_config(
1517                                accept_compression_encodings,
1518                                send_compression_encodings,
1519                            )
1520                            .apply_max_message_size_config(
1521                                max_decoding_message_size,
1522                                max_encoding_message_size,
1523                            );
1524                        let res = grpc.client_streaming(method, req).await;
1525                        Ok(res)
1526                    };
1527                    Box::pin(fut)
1528                }
1529                _ => {
1530                    Box::pin(async move {
1531                        let mut response = http::Response::new(
1532                            tonic::body::Body::default(),
1533                        );
1534                        let headers = response.headers_mut();
1535                        headers
1536                            .insert(
1537                                tonic::Status::GRPC_STATUS,
1538                                (tonic::Code::Unimplemented as i32).into(),
1539                            );
1540                        headers
1541                            .insert(
1542                                http::header::CONTENT_TYPE,
1543                                tonic::metadata::GRPC_CONTENT_TYPE,
1544                            );
1545                        Ok(response)
1546                    })
1547                }
1548            }
1549        }
1550    }
1551    impl<T> Clone for DirectoryServiceServer<T> {
1552        fn clone(&self) -> Self {
1553            let inner = self.inner.clone();
1554            Self {
1555                inner,
1556                accept_compression_encodings: self.accept_compression_encodings,
1557                send_compression_encodings: self.send_compression_encodings,
1558                max_decoding_message_size: self.max_decoding_message_size,
1559                max_encoding_message_size: self.max_encoding_message_size,
1560            }
1561        }
1562    }
1563    /// Generated gRPC service name
1564    pub const SERVICE_NAME: &str = "snix.castore.v1.DirectoryService";
1565    impl<T> tonic::server::NamedService for DirectoryServiceServer<T> {
1566        const NAME: &'static str = SERVICE_NAME;
1567    }
1568}