pub struct ForeignCid(/* private fields */);Expand description
A CID that is not one of this crate’s two mintable profiles.
The inner Cid is private and the only constructors
(new, TryFrom<Cid>, FromStr, from_bytes,
Deserialize) reject a recognized profile, so a ForeignCid can never
alias a ContentId or RawContentId. That is what makes
ClassifiedCid canonical.
A ForeignCid can be carried, compared, linked and rendered. It cannot be
minted here and never becomes a ContentId/RawContentId without re-hashing
the actual content under a profile this crate does mint.
Implementations§
Source§impl ForeignCid
impl ForeignCid
Sourcepub fn new(cid: Cid) -> Result<Self, ContentError>
pub fn new(cid: Cid) -> Result<Self, ContentError>
Wrap a CID that neither mintable profile accepts.
§Errors
ContentError::InvalidCidProfile if cid is a recognized profile
(dag-cbor/BLAKE3 or raw/BLAKE3). Such a CID is not foreign; classify it
with ClassifiedCid::from_cid, which returns the right variant.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, ContentError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, ContentError>
Parse a CID binary envelope that is not a recognized profile.
§Errors
ContentError::InvalidCid if the bytes are not a CID;
ContentError::InvalidCidProfile if they are a recognized profile.
Trait Implementations§
Source§impl Clone for ForeignCid
impl Clone for ForeignCid
impl Copy for ForeignCid
Source§impl Debug for ForeignCid
impl Debug for ForeignCid
Source§impl<'de> Deserialize<'de> for ForeignCid
impl<'de> Deserialize<'de> for ForeignCid
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Validating: a link that is a recognized profile is rejected here rather than admitted as a foreign alias.