pub struct Serializer<A>(/* private fields */);Expand description
Wrap an ArrayBuilder with as a Serializer
To support serialization, the wrapped object must implement
AsMut<ArrayBuilder>. This requirement is covered by ArrayBuilder and
mutable references to an ArrayBuilder.
Calls to serialize will return the Serializer itself on success. Therefore
the the underlying ArrayBuilder passed to Serializer::new and be
retrieved and be used to construct the arrays.
Usage:
use serde_arrow::{ArrayBuilder, Serializer};
let mut builder = ArrayBuilder::from_arrow(&fields)?;
// note: when constructing the serialize with a mutable reference,
// different item sequences can be pushed into the same builder
items1.serialize(Serializer::new(&mut builder))?;
items2.serialize(Serializer::new(&mut builder))?;
let batch = builder.to_record_batch()?;
assert_eq!(batch.num_rows(), items1.len() + items2.len());Implementations§
Source§impl<A> Serializer<A>
impl<A> Serializer<A>
Sourcepub fn new(inner: A) -> Self
pub fn new(inner: A) -> Self
Construct a new serializer from an array builder
See the Serializer docs for details
Sourcepub fn into_inner(self) -> A
pub fn into_inner(self) -> A
Extract the wrapped array builder
Trait Implementations§
Source§impl<A: AsMut<ArrayBuilder>> Serializer for Serializer<A>
impl<A: AsMut<ArrayBuilder>> Serializer for Serializer<A>
Source§type Ok = Serializer<A>
type Ok = Serializer<A>
The output type produced by this
Serializer during successful
serialization. Most serializers that produce text or binary output
should set Ok = () and serialize into an io::Write or buffer
contained within the Serializer instance. Serializers that build
in-memory data structures may be simplified by using Ok to propagate
the data structure around.Source§type SerializeSeq = CollectionSerializer<A>
type SerializeSeq = CollectionSerializer<A>
Type returned from
serialize_seq for serializing the content of the
sequence.Source§type SerializeTuple = CollectionSerializer<A>
type SerializeTuple = CollectionSerializer<A>
Type returned from
serialize_tuple for serializing the content of
the tuple.Source§type SerializeTupleStruct = CollectionSerializer<A>
type SerializeTupleStruct = CollectionSerializer<A>
Type returned from
serialize_tuple_struct for serializing the
content of the tuple struct.Source§type SerializeTupleVariant = CollectionSerializer<A>
type SerializeTupleVariant = CollectionSerializer<A>
Type returned from
serialize_tuple_variant for serializing the
content of the tuple variant.Source§type SerializeMap = Impossible<<Serializer<A> as Serializer>::Ok, <Serializer<A> as Serializer>::Error>
type SerializeMap = Impossible<<Serializer<A> as Serializer>::Ok, <Serializer<A> as Serializer>::Error>
Type returned from
serialize_map for serializing the content of the
map.Source§type SerializeStruct = Impossible<<Serializer<A> as Serializer>::Ok, <Serializer<A> as Serializer>::Error>
type SerializeStruct = Impossible<<Serializer<A> as Serializer>::Ok, <Serializer<A> as Serializer>::Error>
Type returned from
serialize_struct for serializing the content of
the struct.Source§type SerializeStructVariant = Impossible<<Serializer<A> as Serializer>::Ok, <Serializer<A> as Serializer>::Error>
type SerializeStructVariant = Impossible<<Serializer<A> as Serializer>::Ok, <Serializer<A> as Serializer>::Error>
Type returned from
serialize_struct_variant for serializing the
content of the struct variant.Source§fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq>
fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq>
Begin to serialize a variably sized sequence. This call must be
followed by zero or more calls to
serialize_element, then a call to
end. Read moreSource§fn serialize_tuple(self, _: usize) -> Result<Self::SerializeTuple>
fn serialize_tuple(self, _: usize) -> Result<Self::SerializeTuple>
Begin to serialize a statically sized sequence whose length will be
known at deserialization time without looking at the serialized data.
This call must be followed by zero or more calls to
serialize_element,
then a call to end. Read moreSource§fn serialize_tuple_struct(
self,
_: &'static str,
_: usize,
) -> Result<Self::SerializeTupleStruct>
fn serialize_tuple_struct( self, _: &'static str, _: usize, ) -> Result<Self::SerializeTupleStruct>
Begin to serialize a tuple struct like
struct Rgb(u8, u8, u8). This
call must be followed by zero or more calls to serialize_field, then a
call to end. Read moreSource§fn serialize_tuple_variant(
self,
_: &'static str,
_: u32,
_: &'static str,
_: usize,
) -> Result<Self::SerializeTupleVariant>
fn serialize_tuple_variant( self, _: &'static str, _: u32, _: &'static str, _: usize, ) -> Result<Self::SerializeTupleVariant>
Begin to serialize a tuple variant like
E::T in enum E { T(u8, u8) }. This call must be followed by zero or more calls to
serialize_field, then a call to end. Read moreSource§fn serialize_newtype_struct<T: Serialize + ?Sized>(
self,
_: &'static str,
value: &T,
) -> Result<Self::Ok>
fn serialize_newtype_struct<T: Serialize + ?Sized>( self, _: &'static str, value: &T, ) -> Result<Self::Ok>
Serialize a newtype struct like
struct Millimeters(u8). Read moreSource§fn serialize_newtype_variant<T: Serialize + ?Sized>(
self,
_: &'static str,
_: u32,
_: &'static str,
value: &T,
) -> Result<Self::Ok>
fn serialize_newtype_variant<T: Serialize + ?Sized>( self, _: &'static str, _: u32, _: &'static str, value: &T, ) -> Result<Self::Ok>
Source§fn serialize_bytes(self, _: &[u8]) -> Result<Self::Ok>
fn serialize_bytes(self, _: &[u8]) -> Result<Self::Ok>
Serialize a chunk of raw byte data. Read more
Source§fn serialize_map(self, _: Option<usize>) -> Result<Self::SerializeMap>
fn serialize_map(self, _: Option<usize>) -> Result<Self::SerializeMap>
Begin to serialize a map. This call must be followed by zero or more
calls to
serialize_key and serialize_value, then a call to end. Read moreSource§fn serialize_struct(
self,
_: &'static str,
_: usize,
) -> Result<Self::SerializeStruct>
fn serialize_struct( self, _: &'static str, _: usize, ) -> Result<Self::SerializeStruct>
Begin to serialize a struct like
struct Rgb { r: u8, g: u8, b: u8 }.
This call must be followed by zero or more calls to serialize_field,
then a call to end. Read moreSource§fn serialize_struct_variant(
self,
_: &'static str,
_: u32,
_: &'static str,
_: usize,
) -> Result<Self::SerializeStructVariant>
fn serialize_struct_variant( self, _: &'static str, _: u32, _: &'static str, _: usize, ) -> Result<Self::SerializeStructVariant>
Begin to serialize a struct variant like
E::S in enum E { S { r: u8, g: u8, b: u8 } }. This call must be followed by zero or more calls to
serialize_field, then a call to end. Read moreSource§fn serialize_u128(self, _: u128) -> Result<Self::Ok, Self::Error>
fn serialize_u128(self, _: u128) -> Result<Self::Ok, Self::Error>
Serialize a
u128 value. Read moreSource§fn serialize_unit_variant(
self,
_: &'static str,
_: u32,
_: &'static str,
) -> Result<Self::Ok>
fn serialize_unit_variant( self, _: &'static str, _: u32, _: &'static str, ) -> Result<Self::Ok>
Source§fn is_human_readable(&self) -> bool
fn is_human_readable(&self) -> bool
Determine whether
Serialize implementations should serialize in
human-readable form. Read moreSource§fn collect_seq<I>(self, iter: I) -> Result<Self::Ok, Self::Error>
fn collect_seq<I>(self, iter: I) -> Result<Self::Ok, Self::Error>
Collect an iterator as a sequence. Read more
Auto Trait Implementations§
impl<A> Freeze for Serializer<A>where
A: Freeze,
impl<A> RefUnwindSafe for Serializer<A>where
A: RefUnwindSafe,
impl<A> Send for Serializer<A>where
A: Send,
impl<A> Sync for Serializer<A>where
A: Sync,
impl<A> Unpin for Serializer<A>where
A: Unpin,
impl<A> UnwindSafe for Serializer<A>where
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more