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<Self, PrincipalError>
pub fn from_text(text: &str) -> Result<Self, PrincipalError>
Parse canonical textual principal form.
§Errors
Returns PrincipalError::InvalidText for invalid text.
Sourcepub const fn from_slice(bytes: &[u8]) -> Self
pub const fn from_slice(bytes: &[u8]) -> Self
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<Self, PrincipalDecodeError>
pub const fn try_from_bytes(bytes: &[u8]) -> Result<Self, 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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::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§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
impl StructuralPartialEq for Principal
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