pub struct MemoIpld {
    pub parent: Option<Cid>,
    pub headers: Vec<(String, String)>,
    pub body: Cid,
}
Expand description

A basic Memo. A Memo is a history-retaining structure that pairs inline headers with a body CID.

Fields§

§parent: Option<Cid>

An optional pointer to the previous version of the DAG

§headers: Vec<(String, String)>

Headers that are associated with the content of this DAG

§body: Cid

A pointer to the body content

Implementations§

source§

impl MemoIpld

source

pub async fn try_compare_body<S: BlockStore>(&self, store: &S) -> Result<bool>

If the body of this memo is different from it’s parent, returns true.

source

pub async fn diff_headers( &self, other: &MemoIpld ) -> Result<Vec<(String, String)>>

Get the list of headers that either do not appear in other, or have a different value from a same-named header in other

source

pub async fn for_body<S: BlockStore, Body: Serialize + BlockStoreSend>( store: &mut S, body: Body ) -> Result<MemoIpld>

Initializes a memo for the provided body, persisting the body to storage and returning the memo. Note that only the body is persisted, not the memo that wraps it.

source

pub async fn branch_from<S: BlockStore>(cid: &Cid, store: &S) -> Result<Self>

Loads a memo from the provided CID, initializes a copy of it, sets the copy’s parent to the provided CID and cleans signature information from the copy’s headers; the new memo is returned.

source

pub async fn sign<Credential: KeyMaterial>( &mut self, credential: &Credential, authorization: Option<&Authorization> ) -> Result<()>

Sign the memo’s body CID, adding the signature and proof as headers in the memo

source

pub fn get_header(&self, name: &str) -> Vec<String>

Retreive the set of headers that matches the given string name

source

pub fn get_first_header(&self, name: &str) -> Option<String>

Retrieve the first header value (if any) that matches the given header name

source

pub fn expect_header(&self, name: &str, value: &str) -> Result<()>

Asserts that a header with the given name and value exists in the memo

source

pub fn replace_first_header(&mut self, name: &str, value: &str)

Replaces the value of the first header that matches name with provided value

source

pub fn replace_headers(&mut self, new_headers: Vec<(String, String)>)

Replaces all headers in the memo whose names match names that occur in the input list of headers. If multiple headers with the same name already occur in the memo, all of them will be removed. If multiple headers with the same name already occur in the input list, all of them will be included in the new set of headers.

source

pub fn remove_header(&mut self, name: &str)

Removes all headers with the given name from the memo

source

pub fn content_type(&self) -> Option<ContentType>

Helper to quickly deserialize a content-type (if any) from the memo

Trait Implementations§

source§

impl Clone for MemoIpld

source§

fn clone(&self) -> MemoIpld

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MemoIpld

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for MemoIpld

source§

fn default() -> MemoIpld

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for MemoIpld

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Hash for MemoIpld

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<MemoIpld> for MemoIpld

source§

fn eq(&self, other: &MemoIpld) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for MemoIpld

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryBundle for MemoIpld

source§

fn extend_bundle<'life0, 'life1, 'life2, 'async_trait, S>( &'life0 self, bundle: &'life1 mut Bundle, store: &'life2 S ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where S: 'async_trait + BlockStore, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

source§

fn extend_bundle_with_cid<'life0, 'life1, 'life2, 'async_trait, S>( cid: &'life0 Cid, bundle: &'life1 mut Bundle, store: &'life2 S ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where S: 'async_trait + BlockStore, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

source§

fn bundle<'life0, 'life1, 'async_trait, S>( &'life0 self, store: &'life1 S ) -> Pin<Box<dyn Future<Output = Result<Bundle>> + Send + 'async_trait>>where S: 'async_trait + BlockStore, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn bundle_with_cid<'life0, 'life1, 'async_trait, S>( cid: &'life0 Cid, store: &'life1 S ) -> Pin<Box<dyn Future<Output = Result<Bundle>> + Send + 'async_trait>>where S: 'async_trait + BlockStore, Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

impl Eq for MemoIpld

source§

impl StructuralEq for MemoIpld

source§

impl StructuralPartialEq for MemoIpld

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Base64Encode for Twhere T: DagJson,

source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CallHasher for Twhere T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64where H: Hash + ?Sized, B: BuildHasher,

source§

impl<T> DagJson for Twhere T: Serialize + DeserializeOwned,

source§

fn to_dag_json(&self) -> Result<Vec<u8, Global>, Error>

source§

fn from_dag_json(json_bytes: &[u8]) -> Result<Self, Error>

source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> References<RawCodec> for T

source§

fn references<R, E>(_c: RawCodec, _r: &mut R, _set: &mut E) -> Result<(), Error>where R: Read, E: Extend<Cid<64>>,

Scrape the references from an impl Read. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> BlockStoreSend for Twhere T: Send,

source§

impl<T> BlockStoreSendSync for Twhere T: Send + Sync,

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T> KeyValueSendSync for Twhere T: Send + Sync,

source§

impl<T> KeyValueStoreSend for Twhere T: Send,

source§

impl<T> SphereDbSendSync for Twhere T: Send + Sync,

source§

impl<T> StorageSendSync for Twhere T: Send + Sync,

source§

impl<S> StoreConditionalSendSync for Swhere S: Send + Sync,

source§

impl<S> TargetConditionalSendSync for Swhere S: Send + Sync,

source§

impl<U> UcanStoreConditionalSend for Uwhere U: Send,

source§

impl<U> UcanStoreConditionalSendSync for Uwhere U: Send + Sync,