Skip to main content

Handler

Struct Handler 

Source
pub struct Handler { /* private fields */ }
Expand description

Converts between serialized protobuf messages and Arrow record batches for a single message type, exchanging Arrow data through the C Data Interface.

Descriptors are passed as serialized bytes and Arrow data as ArrowArray/ArrowSchema pairs, so this type works with any arrow version on the caller’s side.

Implementations§

Source§

impl Handler

Source

pub fn try_new( file_descriptor_set: &[u8], message_name: &str, config: PtarsConfig, ) -> Result<Self, PtarsError>

Create a handler from a serialized google.protobuf.FileDescriptorSet (e.g. the output of protoc --descriptor_set_out) and a fully qualified message name.

Source

pub fn try_new_from_file_descriptor_protos( file_descriptor_protos: &[&[u8]], message_name: &str, config: PtarsConfig, ) -> Result<Self, PtarsError>

Create a handler from serialized google.protobuf.FileDescriptorProto messages and a fully qualified message name.

Files must be ordered so that imports appear before the files that depend on them.

Source

pub fn arrow_schema(&self) -> Result<ArrowSchema, PtarsError>

The Arrow schema of the record batches produced by Handler::decode, exported as a C Data Interface struct-typed schema.

Source

pub fn decode( &self, array: ArrowArray, schema: &ArrowSchema, ) -> Result<(ArrowArray, ArrowSchema), PtarsError>

Decode an Arrow binary array of serialized protobuf messages into a record batch, returned as a struct-typed array over the C Data Interface.

The input must be a Binary, LargeBinary or BinaryView array where each value is one serialized message; nulls decode to null rows.

Source

pub fn decode_bytes( &self, messages: &[Option<&[u8]>], ) -> Result<(ArrowArray, ArrowSchema), PtarsError>

Decode serialized protobuf messages into a record batch, returned as a struct-typed array over the C Data Interface.

Convenience over Handler::decode for callers that do not already hold the messages in an Arrow array; None decodes to a null row.

Source

pub fn encode( &self, array: ArrowArray, schema: &ArrowSchema, ) -> Result<(ArrowArray, ArrowSchema), PtarsError>

Encode a record batch (passed as a struct-typed array over the C Data Interface) into a Binary array of serialized protobuf messages, returned over the C Data Interface.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.