devtools_wire_format/generated/
rs.devtools.sources.rs

1// This file is @generated by prost-build.
2#[allow(clippy::derive_partial_eq_without_eq)]
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct EntryRequest {
5    /// The path of the directory to list
6    /// This is relative to the workspace root
7    #[prost(string, tag = "1")]
8    pub path: ::prost::alloc::string::String,
9}
10#[allow(clippy::derive_partial_eq_without_eq)]
11#[derive(Clone, PartialEq, ::prost::Message)]
12pub struct Entry {
13    /// The path of the entry relative to the workspace root
14    #[prost(string, tag = "1")]
15    pub path: ::prost::alloc::string::String,
16    /// The size of the entry in bytes
17    #[prost(uint64, tag = "2")]
18    pub size: u64,
19    /// A set of bitflags representing the type of the entry.
20    /// The following entries are defined:
21    /// 1 - Directory
22    /// 2 - File
23    /// 4 - Symbolic Link
24    /// 8 - Asset
25    /// 16 - Resource
26    #[prost(uint32, tag = "3")]
27    pub file_type: u32,
28}
29/// A chunk of bytes that make up a file
30#[allow(clippy::derive_partial_eq_without_eq)]
31#[derive(Clone, PartialEq, ::prost::Message)]
32pub struct Chunk {
33    #[prost(bytes = "bytes", tag = "1")]
34    pub bytes: ::prost::bytes::Bytes,
35}
36/// Generated server implementations.
37#[allow(clippy::all)]
38pub mod sources_server {
39    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
40    use tonic::codegen::*;
41    /// Generated trait containing gRPC methods that should be implemented for use with SourcesServer.
42    #[async_trait]
43    pub trait Sources: Send + Sync + 'static {
44        /// Server streaming response type for the ListEntries method.
45        type ListEntriesStream: tonic::codegen::tokio_stream::Stream<
46                Item = std::result::Result<super::Entry, tonic::Status>,
47            >
48            + Send
49            + 'static;
50        /// Returns the entries of a directory in a streaming way. The idea is that this helps time-to-first-paint especially when the
51        /// folder is large. The client can start rendering the entries as they come in.
52        ///
53        /// Notes:
54        /// - All paths are relative to the workspace root. The idea is that clients do not need to know the absolute position of a workspace and with workspace-relative paths we can reduce the amount of PII sent.
55        /// - This API DOES NOT recursively list workspace entries. The idea is that the client renders a tree-view with all sub-folder collapsed by default and issue a new list_entries call for a sub-folder when a tree node is expanded.
56        /// - File type is a set of bitflags that represent the various properties of the entry. See the `Entry` message for more details.
57        async fn list_entries(
58            &self,
59            request: tonic::Request<super::EntryRequest>,
60        ) -> std::result::Result<
61            tonic::Response<Self::ListEntriesStream>,
62            tonic::Status,
63        >;
64        /// Server streaming response type for the GetEntryBytes method.
65        type GetEntryBytesStream: tonic::codegen::tokio_stream::Stream<
66                Item = std::result::Result<super::Chunk, tonic::Status>,
67            >
68            + Send
69            + 'static;
70        /// Returns the bytes of a file in a streaming way. The idea is that this helps time-to-first-paint especially when the file is large.
71        /// This is done, again, to optimize the time to first paint for assets that are streaming compatible such as images.
72        async fn get_entry_bytes(
73            &self,
74            request: tonic::Request<super::EntryRequest>,
75        ) -> std::result::Result<
76            tonic::Response<Self::GetEntryBytesStream>,
77            tonic::Status,
78        >;
79    }
80    #[derive(Debug)]
81    pub struct SourcesServer<T: Sources> {
82        inner: _Inner<T>,
83        accept_compression_encodings: EnabledCompressionEncodings,
84        send_compression_encodings: EnabledCompressionEncodings,
85        max_decoding_message_size: Option<usize>,
86        max_encoding_message_size: Option<usize>,
87    }
88    struct _Inner<T>(Arc<T>);
89    impl<T: Sources> SourcesServer<T> {
90        pub fn new(inner: T) -> Self {
91            Self::from_arc(Arc::new(inner))
92        }
93        pub fn from_arc(inner: Arc<T>) -> Self {
94            let inner = _Inner(inner);
95            Self {
96                inner,
97                accept_compression_encodings: Default::default(),
98                send_compression_encodings: Default::default(),
99                max_decoding_message_size: None,
100                max_encoding_message_size: None,
101            }
102        }
103        pub fn with_interceptor<F>(
104            inner: T,
105            interceptor: F,
106        ) -> InterceptedService<Self, F>
107        where
108            F: tonic::service::Interceptor,
109        {
110            InterceptedService::new(Self::new(inner), interceptor)
111        }
112        /// Enable decompressing requests with the given encoding.
113        #[must_use]
114        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
115            self.accept_compression_encodings.enable(encoding);
116            self
117        }
118        /// Compress responses with the given encoding, if the client supports it.
119        #[must_use]
120        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
121            self.send_compression_encodings.enable(encoding);
122            self
123        }
124        /// Limits the maximum size of a decoded message.
125        ///
126        /// Default: `4MB`
127        #[must_use]
128        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
129            self.max_decoding_message_size = Some(limit);
130            self
131        }
132        /// Limits the maximum size of an encoded message.
133        ///
134        /// Default: `usize::MAX`
135        #[must_use]
136        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
137            self.max_encoding_message_size = Some(limit);
138            self
139        }
140    }
141    impl<T, B> tonic::codegen::Service<http::Request<B>> for SourcesServer<T>
142    where
143        T: Sources,
144        B: Body + Send + 'static,
145        B::Error: Into<StdError> + Send + 'static,
146    {
147        type Response = http::Response<tonic::body::BoxBody>;
148        type Error = std::convert::Infallible;
149        type Future = BoxFuture<Self::Response, Self::Error>;
150        fn poll_ready(
151            &mut self,
152            _cx: &mut Context<'_>,
153        ) -> Poll<std::result::Result<(), Self::Error>> {
154            Poll::Ready(Ok(()))
155        }
156        fn call(&mut self, req: http::Request<B>) -> Self::Future {
157            let inner = self.inner.clone();
158            match req.uri().path() {
159                "/rs.devtools.sources.Sources/ListEntries" => {
160                    #[allow(non_camel_case_types)]
161                    struct ListEntriesSvc<T: Sources>(pub Arc<T>);
162                    impl<
163                        T: Sources,
164                    > tonic::server::ServerStreamingService<super::EntryRequest>
165                    for ListEntriesSvc<T> {
166                        type Response = super::Entry;
167                        type ResponseStream = T::ListEntriesStream;
168                        type Future = BoxFuture<
169                            tonic::Response<Self::ResponseStream>,
170                            tonic::Status,
171                        >;
172                        fn call(
173                            &mut self,
174                            request: tonic::Request<super::EntryRequest>,
175                        ) -> Self::Future {
176                            let inner = Arc::clone(&self.0);
177                            let fut = async move {
178                                <T as Sources>::list_entries(&inner, request).await
179                            };
180                            Box::pin(fut)
181                        }
182                    }
183                    let accept_compression_encodings = self.accept_compression_encodings;
184                    let send_compression_encodings = self.send_compression_encodings;
185                    let max_decoding_message_size = self.max_decoding_message_size;
186                    let max_encoding_message_size = self.max_encoding_message_size;
187                    let inner = self.inner.clone();
188                    let fut = async move {
189                        let inner = inner.0;
190                        let method = ListEntriesSvc(inner);
191                        let codec = tonic::codec::ProstCodec::default();
192                        let mut grpc = tonic::server::Grpc::new(codec)
193                            .apply_compression_config(
194                                accept_compression_encodings,
195                                send_compression_encodings,
196                            )
197                            .apply_max_message_size_config(
198                                max_decoding_message_size,
199                                max_encoding_message_size,
200                            );
201                        let res = grpc.server_streaming(method, req).await;
202                        Ok(res)
203                    };
204                    Box::pin(fut)
205                }
206                "/rs.devtools.sources.Sources/GetEntryBytes" => {
207                    #[allow(non_camel_case_types)]
208                    struct GetEntryBytesSvc<T: Sources>(pub Arc<T>);
209                    impl<
210                        T: Sources,
211                    > tonic::server::ServerStreamingService<super::EntryRequest>
212                    for GetEntryBytesSvc<T> {
213                        type Response = super::Chunk;
214                        type ResponseStream = T::GetEntryBytesStream;
215                        type Future = BoxFuture<
216                            tonic::Response<Self::ResponseStream>,
217                            tonic::Status,
218                        >;
219                        fn call(
220                            &mut self,
221                            request: tonic::Request<super::EntryRequest>,
222                        ) -> Self::Future {
223                            let inner = Arc::clone(&self.0);
224                            let fut = async move {
225                                <T as Sources>::get_entry_bytes(&inner, request).await
226                            };
227                            Box::pin(fut)
228                        }
229                    }
230                    let accept_compression_encodings = self.accept_compression_encodings;
231                    let send_compression_encodings = self.send_compression_encodings;
232                    let max_decoding_message_size = self.max_decoding_message_size;
233                    let max_encoding_message_size = self.max_encoding_message_size;
234                    let inner = self.inner.clone();
235                    let fut = async move {
236                        let inner = inner.0;
237                        let method = GetEntryBytesSvc(inner);
238                        let codec = tonic::codec::ProstCodec::default();
239                        let mut grpc = tonic::server::Grpc::new(codec)
240                            .apply_compression_config(
241                                accept_compression_encodings,
242                                send_compression_encodings,
243                            )
244                            .apply_max_message_size_config(
245                                max_decoding_message_size,
246                                max_encoding_message_size,
247                            );
248                        let res = grpc.server_streaming(method, req).await;
249                        Ok(res)
250                    };
251                    Box::pin(fut)
252                }
253                _ => {
254                    Box::pin(async move {
255                        Ok(
256                            http::Response::builder()
257                                .status(200)
258                                .header("grpc-status", "12")
259                                .header("content-type", "application/grpc")
260                                .body(empty_body())
261                                .unwrap(),
262                        )
263                    })
264                }
265            }
266        }
267    }
268    impl<T: Sources> Clone for SourcesServer<T> {
269        fn clone(&self) -> Self {
270            let inner = self.inner.clone();
271            Self {
272                inner,
273                accept_compression_encodings: self.accept_compression_encodings,
274                send_compression_encodings: self.send_compression_encodings,
275                max_decoding_message_size: self.max_decoding_message_size,
276                max_encoding_message_size: self.max_encoding_message_size,
277            }
278        }
279    }
280    impl<T: Sources> Clone for _Inner<T> {
281        fn clone(&self) -> Self {
282            Self(Arc::clone(&self.0))
283        }
284    }
285    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
286        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
287            write!(f, "{:?}", self.0)
288        }
289    }
290    impl<T: Sources> tonic::server::NamedService for SourcesServer<T> {
291        const NAME: &'static str = "rs.devtools.sources.Sources";
292    }
293}