Skip to main content

ValueWriter

Struct ValueWriter 

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

Writes valuetype instances with value sharing: the same Rc instance is encoded as an indirection on the second write (one object, not two copies).

Implementations§

Source§

impl ValueWriter

Source

pub fn new() -> Self

Fresh writer (empty sharing table).

Source

pub fn write( &mut self, w: &mut BufferWriter, value: Option<&Rc<dyn ValueMarshal>>, ) -> Result<(), EncodeError>

Writes an optional valuetype: None → null; known instance → indirection; otherwise value_tag(single RepositoryId) + RepositoryId + state.

§Errors

CDR encode error / offset overflow.

Source

pub fn write_with_codebase( &mut self, w: &mut BufferWriter, value: Option<&Rc<dyn ValueMarshal>>, codebase: &str, ) -> Result<(), EncodeError>

Like write, but with a codebase URL (§15.3.4.1, bit 0): value_tag 0x7fffff03, then the codebase URL, then RepositoryId + state. The reader can use the URL via a CodebaseResolver for factory resolution.

§Errors

CDR encode error / offset overflow.

Source

pub fn write_chunked( &mut self, w: &mut BufferWriter, value: Option<&Rc<dyn ValueMarshal>>, base_ids: &[&str], ) -> Result<(), EncodeError>

Writes a valuetype chunked with a RepositoryId list (§15.3.4.3) — the format that makes truncatable valuetypes interoperable over the wire (a foreign ORB can truncate to a base). base_ids are the base RepositoryIds (most-derived → base order); the state lies in one chunk, terminated with end-tag -1. Byte-identical to JacORB 3.9.

§Errors

CDR encode error / offset or length overflow.

Source

pub fn write_chunked_tree( &mut self, w: &mut BufferWriter, node: &ChunkedNode<'_>, ) -> Result<(), EncodeError>

Writes a multi-chunk valuetype tree (§15.3.4.3): a chunked value whose body carries further chunked values at chunk boundaries, each self-delimited by its own end-tag -level. This is the encoder counterpart to the decoder’s nested-chunk handling: where write_chunked emits a single flat state chunk plus an end-tag, this emits the leading state chunk followed by the node’s nested values — the wire a base-only reader truncates over (consuming the derived/nested tail). A leaf node (no nested children) is byte-identical to write_chunked.

§Errors

CDR encode error / offset or length overflow.

Trait Implementations§

Source§

impl Default for ValueWriter

Source§

fn default() -> ValueWriter

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

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.