pub struct CompositeSerializer<S = Infallible, C = Infallible, H = Infallible> { /* private fields */ }
Expand description

A serializer built from composeable pieces.

Implementations§

source§

impl<S, C, H> CompositeSerializer<S, C, H>

source

pub fn new(serializer: S, scratch: C, shared: H) -> Self

Creates a new composite serializer from serializer, scratch, and shared components.

source

pub fn into_components(self) -> (S, C, H)

Consumes the composite serializer and returns the components.

source

pub fn into_serializer(self) -> S

Consumes the composite serializer and returns the serializer.

The scratch space and shared component are discarded.

Trait Implementations§

source§

impl<S: Debug, C: Debug, H: Debug> Debug for CompositeSerializer<S, C, H>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S: Default, C: Default, H: Default> Default for CompositeSerializer<S, C, H>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<S: Fallible, C: Fallible, H: Fallible> Fallible for CompositeSerializer<S, C, H>

§

type Error = CompositeSerializerError<<S as Fallible>::Error, <C as Fallible>::Error, <H as Fallible>::Error>

The error produced by any failing methods.
source§

impl<S: Fallible, C: ScratchSpace, H: Fallible> ScratchSpace for CompositeSerializer<S, C, H>

source§

unsafe fn push_scratch( &mut self, layout: Layout ) -> Result<NonNull<[u8]>, Self::Error>

Allocates scratch space of the requested size. Read more
source§

unsafe fn pop_scratch( &mut self, ptr: NonNull<u8>, layout: Layout ) -> Result<(), Self::Error>

Deallocates previously allocated scratch space. Read more
source§

impl<S: Serializer, C: Fallible, H: Fallible> Serializer for CompositeSerializer<S, C, H>

source§

fn pos(&self) -> usize

Returns the current position of the serializer.
source§

fn write(&mut self, bytes: &[u8]) -> Result<(), Self::Error>

Attempts to write the given bytes to the serializer.
source§

fn pad(&mut self, padding: usize) -> Result<(), Self::Error>

Advances the given number of bytes as padding.
source§

fn align(&mut self, align: usize) -> Result<usize, Self::Error>

Aligns the position of the serializer to the given alignment.
source§

fn align_for<T>(&mut self) -> Result<usize, Self::Error>

Aligns the position of the serializer to be suitable to write the given type.
source§

unsafe fn resolve_aligned<T: Archive + ?Sized>( &mut self, value: &T, resolver: T::Resolver ) -> Result<usize, Self::Error>

Resolves the given value with its resolver and writes the archived type. Read more
source§

unsafe fn resolve_unsized_aligned<T: ArchiveUnsized + ?Sized>( &mut self, value: &T, to: usize, metadata_resolver: T::MetadataResolver ) -> Result<usize, Self::Error>

Resolves the given reference with its resolver and writes the archived reference. Read more
source§

fn serialize_value<T: Serialize<Self>>( &mut self, value: &T ) -> Result<usize, Self::Error>

Archives the given object and returns the position it was archived at.
source§

fn serialize_unsized_value<T: SerializeUnsized<Self> + ?Sized>( &mut self, value: &T ) -> Result<usize, Self::Error>

Archives a reference to the given object and returns the position it was archived at.
source§

impl<S: Fallible, C: Fallible, H: SharedSerializeRegistry> SharedSerializeRegistry for CompositeSerializer<S, C, H>

source§

fn get_shared_ptr(&self, value: *const u8) -> Option<usize>

Gets the position of a previously-added shared pointer. Read more
source§

fn add_shared_ptr( &mut self, value: *const u8, pos: usize ) -> Result<(), Self::Error>

Adds the position of a shared pointer to the registry.
source§

fn get_shared<T: ?Sized>(&self, value: &T) -> Option<usize>

Gets the position of a previously-added shared value. Read more
source§

fn add_shared<T: ?Sized>( &mut self, value: &T, pos: usize ) -> Result<(), Self::Error>

Adds the position of a shared value to the registry.

Auto Trait Implementations§

§

impl<S, C, H> RefUnwindSafe for CompositeSerializer<S, C, H>where C: RefUnwindSafe, H: RefUnwindSafe, S: RefUnwindSafe,

§

impl<S, C, H> Send for CompositeSerializer<S, C, H>where C: Send, H: Send, S: Send,

§

impl<S, C, H> Sync for CompositeSerializer<S, C, H>where C: Sync, H: Sync, S: Sync,

§

impl<S, C, H> Unpin for CompositeSerializer<S, C, H>where C: Unpin, H: Unpin, S: Unpin,

§

impl<S, C, H> UnwindSafe for CompositeSerializer<S, C, H>where C: UnwindSafe, H: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

source§

fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> LayoutRaw for T

source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
source§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.