Skip to main content

MarshalBag

Trait MarshalBag 

Source
pub trait MarshalBag: Copy {
    type Value: Clone;
    type ConstantBag: ConstantBag;

Show 34 methods // Required methods fn make_bool(&self, value: bool) -> Self::Value; fn make_none(&self) -> Self::Value; fn make_ellipsis(&self) -> Self::Value; fn make_float(&self, value: f64) -> Self::Value; fn make_complex(&self, value: Complex<f64>) -> Self::Value; fn make_str(&self, value: &Wtf8) -> Self::Value; fn make_bytes(&self, value: &[u8]) -> Self::Value; fn make_int(&self, value: BigInt) -> Self::Value; fn make_tuple( &self, elements: impl Iterator<Item = Self::Value>, ) -> Self::Value; fn make_code( &self, code: CodeObject<<Self::ConstantBag as ConstantBag>::Constant>, ) -> Result<Self::Value, MarshalError>; fn make_stop_iter(&self) -> Result<Self::Value, MarshalError>; fn make_list( &self, it: impl Iterator<Item = Self::Value>, ) -> Result<Self::Value, MarshalError>; fn make_set( &self, it: impl Iterator<Item = Self::Value>, ) -> Result<Self::Value, MarshalError>; fn make_frozenset( &self, it: impl Iterator<Item = Self::Value>, ) -> Result<Self::Value, MarshalError>; fn make_dict( &self, it: impl Iterator<Item = (Self::Value, Self::Value)>, ) -> Result<Self::Value, MarshalError>; fn constant_bag(self) -> Self::ConstantBag; // Provided methods fn make_interned_str(&self, value: &Wtf8) -> Self::Value { ... } fn make_code_with_constants( &self, code: CodeObject<<Self::ConstantBag as ConstantBag>::Constant>, _constants: Vec<Self::Value>, ) -> Result<Self::Value, MarshalError> { ... } fn code_units_from_bytes( &self, code_bytes: &[u8], ) -> Result<CodeUnits, MarshalError> { ... } fn make_code_with_constants_and_bytes( &self, code: CodeObject<<Self::ConstantBag as ConstantBag>::Constant>, constants: Vec<Self::Value>, _code_bytes: Vec<u8>, ) -> Result<Self::Value, MarshalError> { ... } fn make_tuple_placeholder( &self, _len: usize, ) -> Result<Option<Self::Value>, MarshalError> { ... } fn set_tuple_item( &self, _tuple: &Self::Value, _index: usize, _value: Self::Value, ) -> Result<(), MarshalError> { ... } fn make_list_placeholder( &self, _len: usize, ) -> Result<Option<Self::Value>, MarshalError> { ... } fn set_list_item( &self, _list: &Self::Value, _index: usize, _value: Self::Value, ) -> Result<(), MarshalError> { ... } fn make_set_placeholder(&self) -> Option<Self::Value> { ... } fn insert_set_item( &self, _set: &Self::Value, _value: Self::Value, ) -> Result<(), MarshalError> { ... } fn make_dict_placeholder(&self) -> Option<Self::Value> { ... } fn insert_dict_item( &self, _dict: &Self::Value, _key: Self::Value, _value: Self::Value, ) -> Result<(), MarshalError> { ... } fn make_slice( &self, _start: Self::Value, _stop: Self::Value, _step: Self::Value, ) -> Result<Self::Value, MarshalError> { ... } fn constant_ref_from_value( &self, _value: &Self::Value, ) -> Option<<Self::ConstantBag as ConstantBag>::Constant> { ... } fn code_constant_from_value( &self, value: &Self::Value, ) -> Result<<Self::ConstantBag as ConstantBag>::Constant, MarshalError> { ... } fn bytes_from_value(&self, _value: &Self::Value) -> Option<Vec<u8>> { ... } fn str_from_value(&self, _value: &Self::Value) -> Option<String> { ... } fn tuple_elements_from_value( &self, _value: &Self::Value, ) -> Option<Vec<Self::Value>> { ... }
}

Required Associated Types§

Required Methods§

Source

fn make_bool(&self, value: bool) -> Self::Value

Source

fn make_none(&self) -> Self::Value

Source

fn make_ellipsis(&self) -> Self::Value

Source

fn make_float(&self, value: f64) -> Self::Value

Source

fn make_complex(&self, value: Complex<f64>) -> Self::Value

Source

fn make_str(&self, value: &Wtf8) -> Self::Value

Source

fn make_bytes(&self, value: &[u8]) -> Self::Value

Source

fn make_int(&self, value: BigInt) -> Self::Value

Source

fn make_tuple(&self, elements: impl Iterator<Item = Self::Value>) -> Self::Value

Source

fn make_code( &self, code: CodeObject<<Self::ConstantBag as ConstantBag>::Constant>, ) -> Result<Self::Value, MarshalError>

Source

fn make_stop_iter(&self) -> Result<Self::Value, MarshalError>

Source

fn make_list( &self, it: impl Iterator<Item = Self::Value>, ) -> Result<Self::Value, MarshalError>

Source

fn make_set( &self, it: impl Iterator<Item = Self::Value>, ) -> Result<Self::Value, MarshalError>

Source

fn make_frozenset( &self, it: impl Iterator<Item = Self::Value>, ) -> Result<Self::Value, MarshalError>

Source

fn make_dict( &self, it: impl Iterator<Item = (Self::Value, Self::Value)>, ) -> Result<Self::Value, MarshalError>

Source

fn constant_bag(self) -> Self::ConstantBag

Provided Methods§

Source

fn make_interned_str(&self, value: &Wtf8) -> Self::Value

Source

fn make_code_with_constants( &self, code: CodeObject<<Self::ConstantBag as ConstantBag>::Constant>, _constants: Vec<Self::Value>, ) -> Result<Self::Value, MarshalError>

Construct a runtime code object while retaining the exact values read from co_consts. Compiler bags ignore this second channel; runtime bags use it for marshalable values (lists, dicts, sets, recursive containers) that their compiler constant representation cannot hold.

Source

fn code_units_from_bytes( &self, code_bytes: &[u8], ) -> Result<CodeUnits, MarshalError>

Decode the public co_code byte string into the execution-oriented instruction storage.

Runtime code-object implementations may accept byte values that the compiler’s Instruction enum cannot represent, retaining those bytes separately and substituting a non-executable placeholder here. The default remains the strict compiler representation.

Source

fn make_code_with_constants_and_bytes( &self, code: CodeObject<<Self::ConstantBag as ConstantBag>::Constant>, constants: Vec<Self::Value>, _code_bytes: Vec<u8>, ) -> Result<Self::Value, MarshalError>

Construct a runtime code object while retaining both its exact public co_code bytes and the exact values read from co_consts.

The default ignores the redundant byte spelling because ordinary compiler code is represented losslessly by CodeUnits. Runtime bags that accepted otherwise unrepresentable opcode bytes in MarshalBag::code_units_from_bytes can preserve them here.

Source

fn make_tuple_placeholder( &self, _len: usize, ) -> Result<Option<Self::Value>, MarshalError>

Install partially-built containers in the marshal reference table before reading their children, as CPython’s r_object() does. Runtime bags can opt in; constant bags retain collect-then-construct.

len comes straight from the input and is only bounded by what a length can hold, so a bag that opts in reports the room it cannot get rather than taking it for granted.

Source

fn set_tuple_item( &self, _tuple: &Self::Value, _index: usize, _value: Self::Value, ) -> Result<(), MarshalError>

Source

fn make_list_placeholder( &self, _len: usize, ) -> Result<Option<Self::Value>, MarshalError>

Source

fn set_list_item( &self, _list: &Self::Value, _index: usize, _value: Self::Value, ) -> Result<(), MarshalError>

Source

fn make_set_placeholder(&self) -> Option<Self::Value>

Source

fn insert_set_item( &self, _set: &Self::Value, _value: Self::Value, ) -> Result<(), MarshalError>

Source

fn make_dict_placeholder(&self) -> Option<Self::Value>

Source

fn insert_dict_item( &self, _dict: &Self::Value, _key: Self::Value, _value: Self::Value, ) -> Result<(), MarshalError>

Source

fn make_slice( &self, _start: Self::Value, _stop: Self::Value, _step: Self::Value, ) -> Result<Self::Value, MarshalError>

Source

fn constant_ref_from_value( &self, _value: &Self::Value, ) -> Option<<Self::ConstantBag as ConstantBag>::Constant>

Source

fn code_constant_from_value( &self, value: &Self::Value, ) -> Result<<Self::ConstantBag as ConstantBag>::Constant, MarshalError>

Convert a runtime constant to the compiler-side shape stored in CodeObject. Runtime implementations may return a semantically unused placeholder when the exact value is carried by make_code_with_constants instead.

Source

fn bytes_from_value(&self, _value: &Self::Value) -> Option<Vec<u8>>

Source

fn str_from_value(&self, _value: &Self::Value) -> Option<String>

Source

fn tuple_elements_from_value( &self, _value: &Self::Value, ) -> Option<Vec<Self::Value>>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<Bag> MarshalBag for Bag
where Bag: ConstantBag,