#[non_exhaustive]pub struct Principal {
pub id: PrincipalId,
pub bound_to: Option<PrincipalId>,
pub status: PrincipalStatus,
pub created_at: i64,
}Expand description
The durable principal record stored in cheers’s principal table.
Invariants (enforced by Principal::try_new and the Deserialize impl):
kind == Camp⇒bound_to == Some(PrincipalId { kind: User, .. })kind ∈ {User, Service}⇒bound_to == None
A Camp { bound_to: None } JSON payload is a parse error — see the
roundtrip test in this module.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: PrincipalId§bound_to: Option<PrincipalId>§status: PrincipalStatus§created_at: i64Implementations§
Source§impl Principal
impl Principal
Sourcepub fn try_new(
id: PrincipalId,
bound_to: Option<PrincipalId>,
status: PrincipalStatus,
created_at: i64,
) -> Result<Self, PrincipalError>
pub fn try_new( id: PrincipalId, bound_to: Option<PrincipalId>, status: PrincipalStatus, created_at: i64, ) -> Result<Self, PrincipalError>
Build a Principal and check the kind ↔ bound_to invariants.
Sourcepub fn kind(&self) -> PrincipalKind
pub fn kind(&self) -> PrincipalKind
Convenience accessor — same as self.id.kind.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Principal
impl<'de> Deserialize<'de> for Principal
Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq 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