pub struct Seal<T: Multihash> { /* private fields */ }
Expand description
The Seal
type. See the module level documentation for more.
Implementations
sourceimpl<T: Multihash> Seal<T>
impl<T: Multihash> Seal<T>
pub fn digest(&self) -> &[u8] ⓘ
pub fn tag(&self) -> &T
pub fn digest_hex(&self) -> String
sourcepub fn from_str(input: &str) -> Result<Seal<T>, SealError>
pub fn from_str(input: &str) -> Result<Seal<T>, SealError>
Creates a Seal
from a string. The string must have either the Objecthash prefix
**REDACTED**
or the blot SEAL_MARK
.
You can use [from_bytes
] if you have a list of bytes.
Examples
use blot::seal::Seal;
use blot::multihash::{Multihash, Sha2256};
let seal_classic: Result<Seal<Sha2256>, _> = Seal::from_str("**REDACTED**1220a6a6e5e783c363cd95693ec189c2682315d956869397738679b56305f2095038");
let seal: Result<Seal<Sha2256>, _> = Seal::from_str("771220a6a6e5e783c363cd95693ec189c2682315d956869397738679b56305f2095038");
assert!(seal_classic.is_ok());
assert!(seal.is_ok());
assert_eq!(seal.unwrap(), seal_classic.unwrap());
sourcepub fn from_bytes(bytes: &[u8]) -> Result<Seal<T>, SealError>
pub fn from_bytes(bytes: &[u8]) -> Result<Seal<T>, SealError>
Creates a Seal
from a list of bytes. The first byte must be the
SEAL_MARK
.
You can use [from_str
] if your redacted hash uses the original Objecthash "**REDACTED**"
prefix.
Examples
use blot::seal::Seal;
use blot::multihash::{Multihash, Sha2256};
use hex::FromHex;
let bytes = Vec::from_hex("771220a6a6e5e783c363cd95693ec189c2682315d956869397738679b56305f2095038").unwrap();
let seal: Result<Seal<Sha2256>, _> = Seal::from_bytes(&bytes);
assert!(seal.is_ok());
Errors
This operation fails with SealError::NotRedacted
if the first byte is not 0x77
, the
seal mark.
Trait Implementations
sourceimpl<T: PartialEq + Multihash> PartialEq<Seal<T>> for Seal<T>
impl<T: PartialEq + Multihash> PartialEq<Seal<T>> for Seal<T>
impl<T: Multihash> StructuralPartialEq for Seal<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Seal<T>where
T: RefUnwindSafe,
impl<T> Send for Seal<T>where
T: Send,
impl<T> Sync for Seal<T>where
T: Sync,
impl<T> Unpin for Seal<T>where
T: Unpin,
impl<T> UnwindSafe for Seal<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more