1#[derive(Clone, PartialEq, ::prost::Message)]
5pub struct PathInfo {
6 #[prost(message, optional, tag = "1")]
9 pub entry: ::core::option::Option<::snix_castore::proto::Entry>,
10 #[prost(bytes = "bytes", repeated, tag = "2")]
14 pub references: ::prost::alloc::vec::Vec<::prost::bytes::Bytes>,
15 #[prost(message, optional, tag = "3")]
17 pub narinfo: ::core::option::Option<NarInfo>,
18}
19#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
23pub struct StorePath {
24 #[prost(string, tag = "1")]
26 pub name: ::prost::alloc::string::String,
27 #[prost(bytes = "bytes", tag = "2")]
29 pub digest: ::prost::bytes::Bytes,
30}
31#[derive(Clone, PartialEq, ::prost::Message)]
41pub struct NarInfo {
42 #[prost(uint64, tag = "1")]
44 pub nar_size: u64,
45 #[prost(bytes = "bytes", tag = "2")]
47 pub nar_sha256: ::prost::bytes::Bytes,
48 #[prost(message, repeated, tag = "3")]
50 pub signatures: ::prost::alloc::vec::Vec<nar_info::Signature>,
51 #[prost(string, repeated, tag = "4")]
57 pub reference_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
58 #[prost(message, optional, tag = "5")]
61 pub deriver: ::core::option::Option<StorePath>,
62 #[prost(message, optional, tag = "6")]
86 pub ca: ::core::option::Option<nar_info::Ca>,
87}
88pub mod nar_info {
90 #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
92 pub struct Signature {
93 #[prost(string, tag = "1")]
94 pub name: ::prost::alloc::string::String,
95 #[prost(bytes = "bytes", tag = "2")]
96 pub data: ::prost::bytes::Bytes,
97 }
98 #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
99 pub struct Ca {
100 #[prost(enumeration = "ca::Hash", tag = "1")]
102 pub r#type: i32,
103 #[prost(bytes = "bytes", tag = "2")]
105 pub digest: ::prost::bytes::Bytes,
106 }
107 pub mod ca {
109 #[derive(
110 Clone,
111 Copy,
112 Debug,
113 PartialEq,
114 Eq,
115 Hash,
116 PartialOrd,
117 Ord,
118 ::prost::Enumeration
119 )]
120 #[repr(i32)]
121 pub enum Hash {
122 NarSha256 = 0,
125 NarSha1 = 1,
126 NarSha512 = 2,
127 NarMd5 = 3,
128 TextSha256 = 4,
133 FlatSha1 = 5,
136 FlatMd5 = 6,
137 FlatSha256 = 7,
138 FlatSha512 = 8,
139 }
140 impl Hash {
141 pub fn as_str_name(&self) -> &'static str {
146 match self {
147 Self::NarSha256 => "NAR_SHA256",
148 Self::NarSha1 => "NAR_SHA1",
149 Self::NarSha512 => "NAR_SHA512",
150 Self::NarMd5 => "NAR_MD5",
151 Self::TextSha256 => "TEXT_SHA256",
152 Self::FlatSha1 => "FLAT_SHA1",
153 Self::FlatMd5 => "FLAT_MD5",
154 Self::FlatSha256 => "FLAT_SHA256",
155 Self::FlatSha512 => "FLAT_SHA512",
156 }
157 }
158 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
160 match value {
161 "NAR_SHA256" => Some(Self::NarSha256),
162 "NAR_SHA1" => Some(Self::NarSha1),
163 "NAR_SHA512" => Some(Self::NarSha512),
164 "NAR_MD5" => Some(Self::NarMd5),
165 "TEXT_SHA256" => Some(Self::TextSha256),
166 "FLAT_SHA1" => Some(Self::FlatSha1),
167 "FLAT_MD5" => Some(Self::FlatMd5),
168 "FLAT_SHA256" => Some(Self::FlatSha256),
169 "FLAT_SHA512" => Some(Self::FlatSha512),
170 _ => None,
171 }
172 }
173 }
174 }
175}
176#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
179pub struct GetPathInfoRequest {
180 #[prost(oneof = "get_path_info_request::ByWhat", tags = "1")]
181 pub by_what: ::core::option::Option<get_path_info_request::ByWhat>,
182}
183pub mod get_path_info_request {
185 #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
186 pub enum ByWhat {
187 #[prost(bytes, tag = "1")]
192 ByOutputHash(::prost::bytes::Bytes),
193 }
194}
195#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
198pub struct ListPathInfoRequest {}
199#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
204pub struct CalculateNarResponse {
205 #[prost(uint64, tag = "1")]
207 pub nar_size: u64,
208 #[prost(bytes = "bytes", tag = "2")]
210 pub nar_sha256: ::prost::bytes::Bytes,
211}
212pub mod path_info_service_client {
214 #![allow(
215 unused_variables,
216 dead_code,
217 missing_docs,
218 clippy::wildcard_imports,
219 clippy::let_unit_value,
220 )]
221 use tonic::codegen::*;
222 use tonic::codegen::http::Uri;
223 #[derive(Debug, Clone)]
224 pub struct PathInfoServiceClient<T> {
225 inner: tonic::client::Grpc<T>,
226 }
227 impl PathInfoServiceClient<tonic::transport::Channel> {
228 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
230 where
231 D: TryInto<tonic::transport::Endpoint>,
232 D::Error: Into<StdError>,
233 {
234 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
235 Ok(Self::new(conn))
236 }
237 }
238 impl<T> PathInfoServiceClient<T>
239 where
240 T: tonic::client::GrpcService<tonic::body::Body>,
241 T::Error: Into<StdError>,
242 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
243 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
244 {
245 pub fn new(inner: T) -> Self {
246 let inner = tonic::client::Grpc::new(inner);
247 Self { inner }
248 }
249 pub fn with_origin(inner: T, origin: Uri) -> Self {
250 let inner = tonic::client::Grpc::with_origin(inner, origin);
251 Self { inner }
252 }
253 pub fn with_interceptor<F>(
254 inner: T,
255 interceptor: F,
256 ) -> PathInfoServiceClient<InterceptedService<T, F>>
257 where
258 F: tonic::service::Interceptor,
259 T::ResponseBody: Default,
260 T: tonic::codegen::Service<
261 http::Request<tonic::body::Body>,
262 Response = http::Response<
263 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
264 >,
265 >,
266 <T as tonic::codegen::Service<
267 http::Request<tonic::body::Body>,
268 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
269 {
270 PathInfoServiceClient::new(InterceptedService::new(inner, interceptor))
271 }
272 #[must_use]
277 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
278 self.inner = self.inner.send_compressed(encoding);
279 self
280 }
281 #[must_use]
283 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
284 self.inner = self.inner.accept_compressed(encoding);
285 self
286 }
287 #[must_use]
291 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
292 self.inner = self.inner.max_decoding_message_size(limit);
293 self
294 }
295 #[must_use]
299 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
300 self.inner = self.inner.max_encoding_message_size(limit);
301 self
302 }
303 pub async fn get(
306 &mut self,
307 request: impl tonic::IntoRequest<super::GetPathInfoRequest>,
308 ) -> std::result::Result<tonic::Response<super::PathInfo>, tonic::Status> {
309 self.inner
310 .ready()
311 .await
312 .map_err(|e| {
313 tonic::Status::unknown(
314 format!("Service was not ready: {}", e.into()),
315 )
316 })?;
317 let codec = tonic_prost::ProstCodec::default();
318 let path = http::uri::PathAndQuery::from_static(
319 "/snix.store.v1.PathInfoService/Get",
320 );
321 let mut req = request.into_request();
322 req.extensions_mut()
323 .insert(GrpcMethod::new("snix.store.v1.PathInfoService", "Get"));
324 self.inner.unary(req, path, codec).await
325 }
326 pub async fn put(
338 &mut self,
339 request: impl tonic::IntoRequest<super::PathInfo>,
340 ) -> std::result::Result<tonic::Response<super::PathInfo>, tonic::Status> {
341 self.inner
342 .ready()
343 .await
344 .map_err(|e| {
345 tonic::Status::unknown(
346 format!("Service was not ready: {}", e.into()),
347 )
348 })?;
349 let codec = tonic_prost::ProstCodec::default();
350 let path = http::uri::PathAndQuery::from_static(
351 "/snix.store.v1.PathInfoService/Put",
352 );
353 let mut req = request.into_request();
354 req.extensions_mut()
355 .insert(GrpcMethod::new("snix.store.v1.PathInfoService", "Put"));
356 self.inner.unary(req, path, codec).await
357 }
358 pub async fn calculate_nar(
372 &mut self,
373 request: impl tonic::IntoRequest<::snix_castore::proto::Entry>,
374 ) -> std::result::Result<
375 tonic::Response<super::CalculateNarResponse>,
376 tonic::Status,
377 > {
378 self.inner
379 .ready()
380 .await
381 .map_err(|e| {
382 tonic::Status::unknown(
383 format!("Service was not ready: {}", e.into()),
384 )
385 })?;
386 let codec = tonic_prost::ProstCodec::default();
387 let path = http::uri::PathAndQuery::from_static(
388 "/snix.store.v1.PathInfoService/CalculateNAR",
389 );
390 let mut req = request.into_request();
391 req.extensions_mut()
392 .insert(
393 GrpcMethod::new("snix.store.v1.PathInfoService", "CalculateNAR"),
394 );
395 self.inner.unary(req, path, codec).await
396 }
397 pub async fn list(
400 &mut self,
401 request: impl tonic::IntoRequest<super::ListPathInfoRequest>,
402 ) -> std::result::Result<
403 tonic::Response<tonic::codec::Streaming<super::PathInfo>>,
404 tonic::Status,
405 > {
406 self.inner
407 .ready()
408 .await
409 .map_err(|e| {
410 tonic::Status::unknown(
411 format!("Service was not ready: {}", e.into()),
412 )
413 })?;
414 let codec = tonic_prost::ProstCodec::default();
415 let path = http::uri::PathAndQuery::from_static(
416 "/snix.store.v1.PathInfoService/List",
417 );
418 let mut req = request.into_request();
419 req.extensions_mut()
420 .insert(GrpcMethod::new("snix.store.v1.PathInfoService", "List"));
421 self.inner.server_streaming(req, path, codec).await
422 }
423 }
424}
425pub mod path_info_service_server {
427 #![allow(
428 unused_variables,
429 dead_code,
430 missing_docs,
431 clippy::wildcard_imports,
432 clippy::let_unit_value,
433 )]
434 use tonic::codegen::*;
435 #[async_trait]
437 pub trait PathInfoService: std::marker::Send + std::marker::Sync + 'static {
438 async fn get(
441 &self,
442 request: tonic::Request<super::GetPathInfoRequest>,
443 ) -> std::result::Result<tonic::Response<super::PathInfo>, tonic::Status>;
444 async fn put(
456 &self,
457 request: tonic::Request<super::PathInfo>,
458 ) -> std::result::Result<tonic::Response<super::PathInfo>, tonic::Status>;
459 async fn calculate_nar(
473 &self,
474 request: tonic::Request<::snix_castore::proto::Entry>,
475 ) -> std::result::Result<
476 tonic::Response<super::CalculateNarResponse>,
477 tonic::Status,
478 >;
479 type ListStream: tonic::codegen::tokio_stream::Stream<
481 Item = std::result::Result<super::PathInfo, tonic::Status>,
482 >
483 + std::marker::Send
484 + 'static;
485 async fn list(
488 &self,
489 request: tonic::Request<super::ListPathInfoRequest>,
490 ) -> std::result::Result<tonic::Response<Self::ListStream>, tonic::Status>;
491 }
492 #[derive(Debug)]
493 pub struct PathInfoServiceServer<T> {
494 inner: Arc<T>,
495 accept_compression_encodings: EnabledCompressionEncodings,
496 send_compression_encodings: EnabledCompressionEncodings,
497 max_decoding_message_size: Option<usize>,
498 max_encoding_message_size: Option<usize>,
499 }
500 impl<T> PathInfoServiceServer<T> {
501 pub fn new(inner: T) -> Self {
502 Self::from_arc(Arc::new(inner))
503 }
504 pub fn from_arc(inner: Arc<T>) -> Self {
505 Self {
506 inner,
507 accept_compression_encodings: Default::default(),
508 send_compression_encodings: Default::default(),
509 max_decoding_message_size: None,
510 max_encoding_message_size: None,
511 }
512 }
513 pub fn with_interceptor<F>(
514 inner: T,
515 interceptor: F,
516 ) -> InterceptedService<Self, F>
517 where
518 F: tonic::service::Interceptor,
519 {
520 InterceptedService::new(Self::new(inner), interceptor)
521 }
522 #[must_use]
524 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
525 self.accept_compression_encodings.enable(encoding);
526 self
527 }
528 #[must_use]
530 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
531 self.send_compression_encodings.enable(encoding);
532 self
533 }
534 #[must_use]
538 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
539 self.max_decoding_message_size = Some(limit);
540 self
541 }
542 #[must_use]
546 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
547 self.max_encoding_message_size = Some(limit);
548 self
549 }
550 }
551 impl<T, B> tonic::codegen::Service<http::Request<B>> for PathInfoServiceServer<T>
552 where
553 T: PathInfoService,
554 B: Body + std::marker::Send + 'static,
555 B::Error: Into<StdError> + std::marker::Send + 'static,
556 {
557 type Response = http::Response<tonic::body::Body>;
558 type Error = std::convert::Infallible;
559 type Future = BoxFuture<Self::Response, Self::Error>;
560 fn poll_ready(
561 &mut self,
562 _cx: &mut Context<'_>,
563 ) -> Poll<std::result::Result<(), Self::Error>> {
564 Poll::Ready(Ok(()))
565 }
566 fn call(&mut self, req: http::Request<B>) -> Self::Future {
567 match req.uri().path() {
568 "/snix.store.v1.PathInfoService/Get" => {
569 #[allow(non_camel_case_types)]
570 struct GetSvc<T: PathInfoService>(pub Arc<T>);
571 impl<
572 T: PathInfoService,
573 > tonic::server::UnaryService<super::GetPathInfoRequest>
574 for GetSvc<T> {
575 type Response = super::PathInfo;
576 type Future = BoxFuture<
577 tonic::Response<Self::Response>,
578 tonic::Status,
579 >;
580 fn call(
581 &mut self,
582 request: tonic::Request<super::GetPathInfoRequest>,
583 ) -> Self::Future {
584 let inner = Arc::clone(&self.0);
585 let fut = async move {
586 <T as PathInfoService>::get(&inner, request).await
587 };
588 Box::pin(fut)
589 }
590 }
591 let accept_compression_encodings = self.accept_compression_encodings;
592 let send_compression_encodings = self.send_compression_encodings;
593 let max_decoding_message_size = self.max_decoding_message_size;
594 let max_encoding_message_size = self.max_encoding_message_size;
595 let inner = self.inner.clone();
596 let fut = async move {
597 let method = GetSvc(inner);
598 let codec = tonic_prost::ProstCodec::default();
599 let mut grpc = tonic::server::Grpc::new(codec)
600 .apply_compression_config(
601 accept_compression_encodings,
602 send_compression_encodings,
603 )
604 .apply_max_message_size_config(
605 max_decoding_message_size,
606 max_encoding_message_size,
607 );
608 let res = grpc.unary(method, req).await;
609 Ok(res)
610 };
611 Box::pin(fut)
612 }
613 "/snix.store.v1.PathInfoService/Put" => {
614 #[allow(non_camel_case_types)]
615 struct PutSvc<T: PathInfoService>(pub Arc<T>);
616 impl<T: PathInfoService> tonic::server::UnaryService<super::PathInfo>
617 for PutSvc<T> {
618 type Response = super::PathInfo;
619 type Future = BoxFuture<
620 tonic::Response<Self::Response>,
621 tonic::Status,
622 >;
623 fn call(
624 &mut self,
625 request: tonic::Request<super::PathInfo>,
626 ) -> Self::Future {
627 let inner = Arc::clone(&self.0);
628 let fut = async move {
629 <T as PathInfoService>::put(&inner, request).await
630 };
631 Box::pin(fut)
632 }
633 }
634 let accept_compression_encodings = self.accept_compression_encodings;
635 let send_compression_encodings = self.send_compression_encodings;
636 let max_decoding_message_size = self.max_decoding_message_size;
637 let max_encoding_message_size = self.max_encoding_message_size;
638 let inner = self.inner.clone();
639 let fut = async move {
640 let method = PutSvc(inner);
641 let codec = tonic_prost::ProstCodec::default();
642 let mut grpc = tonic::server::Grpc::new(codec)
643 .apply_compression_config(
644 accept_compression_encodings,
645 send_compression_encodings,
646 )
647 .apply_max_message_size_config(
648 max_decoding_message_size,
649 max_encoding_message_size,
650 );
651 let res = grpc.unary(method, req).await;
652 Ok(res)
653 };
654 Box::pin(fut)
655 }
656 "/snix.store.v1.PathInfoService/CalculateNAR" => {
657 #[allow(non_camel_case_types)]
658 struct CalculateNARSvc<T: PathInfoService>(pub Arc<T>);
659 impl<
660 T: PathInfoService,
661 > tonic::server::UnaryService<::snix_castore::proto::Entry>
662 for CalculateNARSvc<T> {
663 type Response = super::CalculateNarResponse;
664 type Future = BoxFuture<
665 tonic::Response<Self::Response>,
666 tonic::Status,
667 >;
668 fn call(
669 &mut self,
670 request: tonic::Request<::snix_castore::proto::Entry>,
671 ) -> Self::Future {
672 let inner = Arc::clone(&self.0);
673 let fut = async move {
674 <T as PathInfoService>::calculate_nar(&inner, request).await
675 };
676 Box::pin(fut)
677 }
678 }
679 let accept_compression_encodings = self.accept_compression_encodings;
680 let send_compression_encodings = self.send_compression_encodings;
681 let max_decoding_message_size = self.max_decoding_message_size;
682 let max_encoding_message_size = self.max_encoding_message_size;
683 let inner = self.inner.clone();
684 let fut = async move {
685 let method = CalculateNARSvc(inner);
686 let codec = tonic_prost::ProstCodec::default();
687 let mut grpc = tonic::server::Grpc::new(codec)
688 .apply_compression_config(
689 accept_compression_encodings,
690 send_compression_encodings,
691 )
692 .apply_max_message_size_config(
693 max_decoding_message_size,
694 max_encoding_message_size,
695 );
696 let res = grpc.unary(method, req).await;
697 Ok(res)
698 };
699 Box::pin(fut)
700 }
701 "/snix.store.v1.PathInfoService/List" => {
702 #[allow(non_camel_case_types)]
703 struct ListSvc<T: PathInfoService>(pub Arc<T>);
704 impl<
705 T: PathInfoService,
706 > tonic::server::ServerStreamingService<super::ListPathInfoRequest>
707 for ListSvc<T> {
708 type Response = super::PathInfo;
709 type ResponseStream = T::ListStream;
710 type Future = BoxFuture<
711 tonic::Response<Self::ResponseStream>,
712 tonic::Status,
713 >;
714 fn call(
715 &mut self,
716 request: tonic::Request<super::ListPathInfoRequest>,
717 ) -> Self::Future {
718 let inner = Arc::clone(&self.0);
719 let fut = async move {
720 <T as PathInfoService>::list(&inner, request).await
721 };
722 Box::pin(fut)
723 }
724 }
725 let accept_compression_encodings = self.accept_compression_encodings;
726 let send_compression_encodings = self.send_compression_encodings;
727 let max_decoding_message_size = self.max_decoding_message_size;
728 let max_encoding_message_size = self.max_encoding_message_size;
729 let inner = self.inner.clone();
730 let fut = async move {
731 let method = ListSvc(inner);
732 let codec = tonic_prost::ProstCodec::default();
733 let mut grpc = tonic::server::Grpc::new(codec)
734 .apply_compression_config(
735 accept_compression_encodings,
736 send_compression_encodings,
737 )
738 .apply_max_message_size_config(
739 max_decoding_message_size,
740 max_encoding_message_size,
741 );
742 let res = grpc.server_streaming(method, req).await;
743 Ok(res)
744 };
745 Box::pin(fut)
746 }
747 _ => {
748 Box::pin(async move {
749 let mut response = http::Response::new(
750 tonic::body::Body::default(),
751 );
752 let headers = response.headers_mut();
753 headers
754 .insert(
755 tonic::Status::GRPC_STATUS,
756 (tonic::Code::Unimplemented as i32).into(),
757 );
758 headers
759 .insert(
760 http::header::CONTENT_TYPE,
761 tonic::metadata::GRPC_CONTENT_TYPE,
762 );
763 Ok(response)
764 })
765 }
766 }
767 }
768 }
769 impl<T> Clone for PathInfoServiceServer<T> {
770 fn clone(&self) -> Self {
771 let inner = self.inner.clone();
772 Self {
773 inner,
774 accept_compression_encodings: self.accept_compression_encodings,
775 send_compression_encodings: self.send_compression_encodings,
776 max_decoding_message_size: self.max_decoding_message_size,
777 max_encoding_message_size: self.max_encoding_message_size,
778 }
779 }
780 }
781 pub const SERVICE_NAME: &str = "snix.store.v1.PathInfoService";
783 impl<T> tonic::server::NamedService for PathInfoServiceServer<T> {
784 const NAME: &'static str = SERVICE_NAME;
785 }
786}