pub struct Principal(/* private fields */);Expand description
Canonical principal atom.
Implementations§
Source§impl Principal
impl Principal
Sourcepub const MAX_LENGTH_IN_BYTES: u32 = 29
pub const MAX_LENGTH_IN_BYTES: u32 = 29
Maximum canonical principal byte length.
Sourcepub fn from_text(text: &str) -> Result<Principal, PrincipalError>
pub fn from_text(text: &str) -> Result<Principal, PrincipalError>
Parse canonical textual principal form.
§Errors
Returns PrincipalError::InvalidText for invalid text.
Sourcepub const fn from_slice(bytes: &[u8]) -> Principal
pub const fn from_slice(bytes: &[u8]) -> Principal
Construct from canonical principal bytes.
§Panics
Panics when bytes exceeds the canonical 29-byte principal limit.
Use Principal::try_from_bytes for untrusted input.
Sourcepub const fn stored_bytes(&self) -> Result<&[u8], PrincipalEncodeError>
pub const fn stored_bytes(&self) -> Result<&[u8], PrincipalEncodeError>
Borrow bounded canonical bytes.
§Errors
Returns a typed error if an upstream value violates the canonical principal length.
Sourcepub const fn try_from_bytes(
bytes: &[u8],
) -> Result<Principal, PrincipalDecodeError>
pub const fn try_from_bytes( bytes: &[u8], ) -> Result<Principal, PrincipalDecodeError>
Decode bounded canonical bytes.
§Errors
Returns a typed error when bytes exceeds the principal bound.
Trait Implementations§
Source§impl CandidType for Principal
impl CandidType for Principal
impl Copy for Principal
Source§impl<'de> Deserialize<'de> for Principal
impl<'de> Deserialize<'de> for Principal
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Principal, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Principal, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Principal
Source§impl From<Principal> for Subaccount
impl From<Principal> for Subaccount
Source§fn from(principal: Principal) -> Subaccount
fn from(principal: Principal) -> Subaccount
Converts to this type from the input type.
Source§impl NormalizeAuto for Principal
impl NormalizeAuto for Principal
fn normalize_self(&mut self, _ctx: &mut dyn VisitorContext)
Source§impl NormalizeCustom for Principal
impl NormalizeCustom for Principal
fn normalize_custom(&mut self, _ctx: &mut dyn VisitorContext)
Source§impl Ord for Principal
impl Ord for Principal
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Principal
impl PartialOrd for Principal
Source§impl Serialize for Principal
impl Serialize for Principal
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for Principal
Source§impl ValidateAuto for Principal
impl ValidateAuto for Principal
fn validate_self(&self, _ctx: &mut dyn VisitorContext)
Source§impl ValidateCustom for Principal
impl ValidateCustom for Principal
fn validate_custom(&self, _ctx: &mut dyn VisitorContext)
Auto Trait Implementations§
impl Freeze for Principal
impl RefUnwindSafe for Principal
impl Send for Principal
impl Sync for Principal
impl Unpin for Principal
impl UnsafeUnpin for Principal
impl UnwindSafe for Principal
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> CustomError for T
impl<T> CustomError for T
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§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
Compare self to
key and return true if they are equal.impl<T> Normalize for Twhere
T: NormalizeAuto + NormalizeCustom,
Source§impl<T> NormalizeAndValidate for Twhere
T: Visitable,
impl<T> NormalizeAndValidate for Twhere
T: Visitable,
Source§fn normalize_and_validate(self) -> Result<Self, VisitorError>
fn normalize_and_validate(self) -> Result<Self, VisitorError>
Normalize and then validate this application-owned value. Read more