diff --git a/Cargo.toml b/Cargo.toml index a9c5ea9..b7f2e1f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,9 +14,9 @@ description = "Unofficial flatbuffers and tonic code of Apache Arrow spec" [dependencies] planus = { version = "0.3.1", optional = true } serde = { version = "1", optional = true, default-features = false, features = ["derive", "std"] } -tonic = { version = "0.7.0", optional = true } -prost = { version = "0.10.0", optional = true } -prost-derive = { version = "0.10.0", optional = true } +tonic = { version = "0.8.0", optional = true } +prost = { version = "0.11.0", optional = true } +prost-derive = { version = "0.11.0", optional = true } [features] default = [] diff --git a/src/flight/data.rs b/src/flight/data.rs index 8bcbb8c..1cb87ce 100644 --- a/src/flight/data.rs +++ b/src/flight/data.rs @@ -75,9 +75,9 @@ pub struct Result { #[derive(Clone, PartialEq, ::prost::Message)] pub struct SchemaResult { /// The schema of the dataset in its IPC form: - /// 4 bytes - an optional IPC_CONTINUATION_TOKEN prefix - /// 4 bytes - the byte length of the payload - /// a flatbuffer Message whose header is the Schema + /// 4 bytes - an optional IPC_CONTINUATION_TOKEN prefix + /// 4 bytes - the byte length of the payload + /// a flatbuffer Message whose header is the Schema #[prost(bytes = "vec", tag = "1")] pub schema: ::prost::alloc::vec::Vec, } @@ -111,12 +111,25 @@ pub mod flight_descriptor { /// /// A named path that identifies a dataset. A path is composed of a string /// or list of strings describing a particular dataset. This is conceptually - /// similar to a path inside a filesystem. + /// similar to a path inside a filesystem. Path = 1, /// /// An opaque command to generate a dataset. Cmd = 2, } + impl DescriptorType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + DescriptorType::Unknown => "UNKNOWN", + DescriptorType::Path => "PATH", + DescriptorType::Cmd => "CMD", + } + } + } } /// /// The access coordinates for retrieval of a dataset. With a FlightInfo, a @@ -124,9 +137,9 @@ pub mod flight_descriptor { #[derive(Clone, PartialEq, ::prost::Message)] pub struct FlightInfo { /// The schema of the dataset in its IPC form: - /// 4 bytes - an optional IPC_CONTINUATION_TOKEN prefix - /// 4 bytes - the byte length of the payload - /// a flatbuffer Message whose header is the Schema + /// 4 bytes - an optional IPC_CONTINUATION_TOKEN prefix + /// 4 bytes - the byte length of the payload + /// a flatbuffer Message whose header is the Schema #[prost(bytes = "vec", tag = "1")] pub schema: ::prost::alloc::vec::Vec, /// @@ -221,7 +234,7 @@ pub struct FlightData { #[prost(bytes = "vec", tag = "1000")] pub data_body: ::prost::alloc::vec::Vec, } -///* +/// * /// The response message associated with the submission of a DoPut. #[derive(Clone, PartialEq, ::prost::Message)] pub struct PutResult { diff --git a/src/flight/service.rs b/src/flight/service.rs index cea3851..6032ca4 100644 --- a/src/flight/service.rs +++ b/src/flight/service.rs @@ -3,6 +3,7 @@ use super::data::*; /// Generated client implementations. pub mod flight_service_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::http::Uri; use tonic::codegen::*; /// /// A flight service is an endpoint for retrieving or storing Arrow data. A @@ -35,6 +36,10 @@ pub mod flight_service_client { let inner = tonic::client::Grpc::new(inner); Self { inner } } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } pub fn with_interceptor( inner: T, interceptor: F, @@ -53,19 +58,19 @@ pub mod flight_service_client { { FlightServiceClient::new(InterceptedService::new(inner, interceptor)) } - /// Compress requests with `gzip`. + /// Compress requests with the given encoding. /// /// This requires the server to support it otherwise it might respond with an /// error. #[must_use] - pub fn send_gzip(mut self) -> Self { - self.inner = self.inner.send_gzip(); + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); self } - /// Enable decompressing responses with `gzip`. + /// Enable decompressing responses. #[must_use] - pub fn accept_gzip(mut self) -> Self { - self.inner = self.inner.accept_gzip(); + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); self } /// @@ -427,8 +432,8 @@ pub mod flight_service_server { #[derive(Debug)] pub struct FlightServiceServer { inner: _Inner, - accept_compression_encodings: (), - send_compression_encodings: (), + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, } struct _Inner(Arc); impl FlightServiceServer { @@ -449,6 +454,18 @@ pub mod flight_service_server { { InterceptedService::new(Self::new(inner), interceptor) } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } } impl tonic::codegen::Service> for FlightServiceServer where @@ -786,7 +803,7 @@ pub mod flight_service_server { write!(f, "{:?}", self.0) } } - impl tonic::transport::NamedService for FlightServiceServer { + impl tonic::server::NamedService for FlightServiceServer { const NAME: &'static str = "arrow.flight.protocol.FlightService"; } }