Skip to main content

ObjectDetails

Trait ObjectDetails 

Source
pub trait ObjectDetails: Sized {
    type Identifier: Display;

    const PREFIX: &'static str;

    // Required methods
    fn object_id(&self) -> &Self::Identifier;
    fn from_bytes(bytes: Bytes) -> Result<Self>;
    fn to_put_payload(&self) -> Result<PutPayload>;

    // Provided method
    fn path_for(id: &Self::Identifier) -> Path { ... }
}
Expand description

Details on how to store this type in the object store.

You probably want to implement this trait via JsonObjectDetails.

Required Associated Constants§

Source

const PREFIX: &'static str

Required Associated Types§

Required Methods§

Source

fn object_id(&self) -> &Self::Identifier

Source

fn from_bytes(bytes: Bytes) -> Result<Self>

Source

fn to_put_payload(&self) -> Result<PutPayload>

Turn this object into one (or more) bytes::Bytes

Provided Methods§

Source

fn path_for(id: &Self::Identifier) -> Path

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§

Source§

impl ObjectDetails for UserObject

Source§

const PREFIX: &str = "user-obj"

Source§

type Identifier = Id

Source§

impl<T: JsonObjectDetails> ObjectDetails for T

Source§

const PREFIX: &str = <T as JsonObjectDetails>::PREFIX

Source§

type Identifier = <T as JsonObjectDetails>::Identifier