Trait StoredObject

Source
pub trait StoredObject: Sized {
    type Key<'a>: Copy;

    const BUCKET: Bucket;

    // Required methods
    fn encode_key(key: Self::Key<'_>) -> String;
    fn serialize(&self) -> Result<Vec<u8>, BoxedError>;
    fn deserialize(bytes: Vec<u8>) -> Result<Self, BoxedError>;
}
Expand description

Object that can be stored in an ObjectStore.

Required Associated Constants§

Source

const BUCKET: Bucket

Bucket in which values are stored.

Required Associated Types§

Source

type Key<'a>: Copy

Logical unique key for the object. The lifetime param allows defining keys that borrow data; see [CircuitKey] for an example.

Required Methods§

Source

fn encode_key(key: Self::Key<'_>) -> String

Encodes the object key to a string.

Source

fn serialize(&self) -> Result<Vec<u8>, BoxedError>

Serializes a value to a blob.

§Errors

Returns an error if serialization fails.

Source

fn deserialize(bytes: Vec<u8>) -> Result<Self, BoxedError>

Deserializes a value from the blob.

§Errors

Returns an error if deserialization fails.

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.

Implementations on Foreign Types§

Source§

impl StoredObject for SnapshotFactoryDependencies

Source§

const BUCKET: Bucket = Bucket::StorageSnapshot

Source§

type Key<'a> = L1BatchNumber

Source§

fn encode_key(key: Self::Key<'_>) -> String

Source§

fn serialize(&self) -> Result<Vec<u8>, BoxedError>

Source§

fn deserialize(bytes: Vec<u8>) -> Result<Self, BoxedError>

Source§

impl<K> StoredObject for SnapshotStorageLogsChunk<K>
where Self: ProtoFmt,

Source§

const BUCKET: Bucket = Bucket::StorageSnapshot

Source§

type Key<'a> = SnapshotStorageLogsStorageKey

Source§

fn encode_key(key: Self::Key<'_>) -> String

Source§

fn serialize(&self) -> Result<Vec<u8>, BoxedError>

Source§

fn deserialize(bytes: Vec<u8>) -> Result<Self, BoxedError>

Implementors§