Skip to main content

LinksObject

Trait LinksObject 

Source
pub trait LinksObject: Default + 'static {
    const TYPE_NAME: &'static str;

    // Required methods
    fn type_shape() -> RustTypeShape;
    fn encode_fields(&self, encoder: &mut LinksEncoder, object: LinkId);
    fn decode_fields(
        &mut self,
        decoder: &mut LinksDecoder<'_>,
        object: LinkId,
    ) -> Result<(), LinksCodecError>;
}
Expand description

Helper trait for user-defined object types that need identity preservation.

Implement this for structs that may be shared or cyclic through Rc<RefCell<T>>. decode_fields mutates an already-allocated default value, which lets the decoder register an identity before recursively decoding fields that may point back to the same object.

Required Associated Constants§

Source

const TYPE_NAME: &'static str

Stable Rust type name stored in the type-shape link.

Required Methods§

Source

fn type_shape() -> RustTypeShape

Queryable type declaration shape.

Source

fn encode_fields(&self, encoder: &mut LinksEncoder, object: LinkId)

Encodes object fields after an identity link has been allocated.

Source

fn decode_fields( &mut self, decoder: &mut LinksDecoder<'_>, object: LinkId, ) -> Result<(), LinksCodecError>

Decodes fields into an already-allocated object.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§