devtools_wire_format/generated/
rs.devtools.sources.rs1#[allow(clippy::derive_partial_eq_without_eq)]
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct EntryRequest {
5 #[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 #[prost(string, tag = "1")]
15 pub path: ::prost::alloc::string::String,
16 #[prost(uint64, tag = "2")]
18 pub size: u64,
19 #[prost(uint32, tag = "3")]
27 pub file_type: u32,
28}
29#[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#[allow(clippy::all)]
38pub mod sources_server {
39 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
40 use tonic::codegen::*;
41 #[async_trait]
43 pub trait Sources: Send + Sync + 'static {
44 type ListEntriesStream: tonic::codegen::tokio_stream::Stream<
46 Item = std::result::Result<super::Entry, tonic::Status>,
47 >
48 + Send
49 + 'static;
50 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 type GetEntryBytesStream: tonic::codegen::tokio_stream::Stream<
66 Item = std::result::Result<super::Chunk, tonic::Status>,
67 >
68 + Send
69 + 'static;
70 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 #[must_use]
114 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
115 self.accept_compression_encodings.enable(encoding);
116 self
117 }
118 #[must_use]
120 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
121 self.send_compression_encodings.enable(encoding);
122 self
123 }
124 #[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 #[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}