Skip to main content

EncoderDesc

Struct EncoderDesc 

Source
#[repr(C)]
pub struct EncoderDesc { pub name: &'static str, pub write_envelope: fn(&mut dyn Write, &Machine, &Envelope<'_>) -> Result<()>, pub write_error: fn(&mut dyn Write, &WireError) -> Result<()>, pub can_stream: fn() -> bool, }
Expand description

An encoding as a vtable: a name plus the three operations the wire contract needs. #[repr(C)] so codegen can reference a descriptor by address and entry.rs can read its fields after dereferencing the pointer from the capability table. A #[no_mangle] static of this type per encoding (PLG_ENC_TEXT, PLG_ENC_BSON) is what codegen’s @plg_caps table points at; encoders not listed there are unreferenced and get dead-stripped.

Fields§

§name: &'static str

The --format name this descriptor answers to (“text”, “bson”).

§write_envelope: fn(&mut dyn Write, &Machine, &Envelope<'_>) -> Result<()>§write_error: fn(&mut dyn Write, &WireError) -> Result<()>§can_stream: fn() -> bool

False ⇒ the encoding can’t coexist with streamed write/1 bytes on the same stdout (binary formats), so the caller must run in capture mode.

Implementations§

Source§

impl EncoderDesc

Source

pub unsafe fn find( caps: *const *const EncoderDesc, len: usize, name: &str, ) -> Option<&'static EncoderDesc>

Find a descriptor by name in a capability table (codegen-baked pointers to #[no_mangle] static descriptors). Returns None when the name isn’t advertised — entry.rs maps that to a usage error (exit 2).

§Safety

caps must point at len valid pointers to static descriptors.

Auto Trait Implementations§

Blanket Implementations§

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<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, 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.