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§
Required Methods§
Sourcefn type_shape() -> RustTypeShape
fn type_shape() -> RustTypeShape
Queryable type declaration shape.
Sourcefn encode_fields(&self, encoder: &mut LinksEncoder, object: LinkId)
fn encode_fields(&self, encoder: &mut LinksEncoder, object: LinkId)
Encodes object fields after an identity link has been allocated.
Sourcefn decode_fields(
&mut self,
decoder: &mut LinksDecoder<'_>,
object: LinkId,
) -> Result<(), LinksCodecError>
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.