#[non_exhaustive]pub struct MetadataEntry {
pub content: Hash,
pub key: String,
pub value: String,
pub author: String,
pub sequence: u64,
pub created_at: u64,
pub signature: Option<String>,
}Expand description
Signed metadata appended to a content hash.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.content: Hash§key: String§value: String§sequence: u64§created_at: u64§signature: Option<String>Implementations§
Source§impl MetadataEntry
impl MetadataEntry
Sourcepub fn new(
content: Hash,
key: impl Into<String>,
value: impl Into<String>,
sequence: u64,
signing_key: &SigningKey,
) -> Result<Self>
pub fn new( content: Hash, key: impl Into<String>, value: impl Into<String>, sequence: u64, signing_key: &SigningKey, ) -> Result<Self>
Create and sign metadata with an Ed25519 author key.
§Errors
Returns an error if metadata fields are invalid or signing fails.
Sourcepub fn new_with_time(
content: Hash,
key: impl Into<String>,
value: impl Into<String>,
sequence: u64,
created_at: u64,
signing_key: &SigningKey,
) -> Result<Self>
pub fn new_with_time( content: Hash, key: impl Into<String>, value: impl Into<String>, sequence: u64, created_at: u64, signing_key: &SigningKey, ) -> Result<Self>
Create and sign metadata with an explicit timestamp.
§Errors
Returns an error if metadata fields are invalid or signing fails.
Sourcepub fn unsigned(
content: Hash,
key: impl Into<String>,
value: impl Into<String>,
sequence: u64,
created_at: u64,
author: &VerifyingKey,
) -> Result<Self>
pub fn unsigned( content: Hash, key: impl Into<String>, value: impl Into<String>, sequence: u64, created_at: u64, author: &VerifyingKey, ) -> Result<Self>
Create unsigned metadata for a specific author identity.
Call Self::sign before accepting or serializing the entry.
§Errors
Returns an error if metadata fields are invalid.
Sourcepub fn sign(&mut self, signing_key: &SigningKey) -> Result<()>
pub fn sign(&mut self, signing_key: &SigningKey) -> Result<()>
Sign the entry with its declared author.
§Errors
Returns an error if the signing key does not match the author.
Sourcepub fn verify_signature(&self) -> Result<()>
pub fn verify_signature(&self) -> Result<()>
Verify the metadata signature and structure.
§Errors
Returns an error if the metadata or signature is invalid.
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate non-cryptographic metadata fields.
§Errors
Returns an error if a required field or author identity is invalid.
Trait Implementations§
Source§impl Clone for MetadataEntry
impl Clone for MetadataEntry
Source§fn clone(&self) -> MetadataEntry
fn clone(&self) -> MetadataEntry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MetadataEntry
impl Debug for MetadataEntry
Source§impl<'de> Deserialize<'de> for MetadataEntry
impl<'de> Deserialize<'de> for MetadataEntry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for MetadataEntry
Source§impl PartialEq for MetadataEntry
impl PartialEq for MetadataEntry
Source§impl Serialize for MetadataEntry
impl Serialize for MetadataEntry
impl StructuralPartialEq for MetadataEntry
Auto Trait Implementations§
impl Freeze for MetadataEntry
impl RefUnwindSafe for MetadataEntry
impl Send for MetadataEntry
impl Sync for MetadataEntry
impl Unpin for MetadataEntry
impl UnsafeUnpin for MetadataEntry
impl UnwindSafe for MetadataEntry
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more