Skip to main content

OpaqueType

Trait OpaqueType 

Source
pub trait OpaqueType: Sized {
    const TYPE_NAME: &'static str;

    // Required methods
    fn encode(&self) -> Bytes;
    fn try_decode(data: Bytes) -> Result<Self, GenericError>;
}
Expand description

A type that can be encoded into, and decoded from, an Opaque value.

Required Associated Constants§

Source

const TYPE_NAME: &'static str

The fully qualified type name.

Required Methods§

Source

fn encode(&self) -> Bytes

Encodes this value.

Source

fn try_decode(data: Bytes) -> Result<Self, GenericError>

Decodes a value from the given data.

§Errors

If the data isn’t a valid encoding of this type, an error is returned.

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§