pub trait AddOnlyPeopleTrait {
type Member: Parameter + MaxEncodedLen;
// Required methods
fn reserve_new_id() -> PersonalId;
fn renew_id_reservation(
personal_id: PersonalId,
) -> Result<(), DispatchError>;
fn cancel_id_reservation(
personal_id: PersonalId,
) -> Result<(), DispatchError>;
fn recognize_personhood(
who: PersonalId,
maybe_key: Option<Self::Member>,
) -> Result<(), DispatchError>;
}
Expand description
Trait to recognize people and handle personal id.
PersonalId
goes through multiple state: free, reserved, used; a used personal id can belong
to a recognized person or a suspended person.
Required Associated Types§
type Member: Parameter + MaxEncodedLen
Required Methods§
Sourcefn reserve_new_id() -> PersonalId
fn reserve_new_id() -> PersonalId
Reserve a new id for a future person. This id is not recognized, not reserved, and has never been reserved in the past.
Sourcefn renew_id_reservation(personal_id: PersonalId) -> Result<(), DispatchError>
fn renew_id_reservation(personal_id: PersonalId) -> Result<(), DispatchError>
Renew a reservation for a personal id. The id is not recognized, but has been reserved in the past.
An error is returned if the id is used or wasn’t reserved before.
Sourcefn cancel_id_reservation(personal_id: PersonalId) -> Result<(), DispatchError>
fn cancel_id_reservation(personal_id: PersonalId) -> Result<(), DispatchError>
Cancel the reservation for a personal id
An error is returned if the id wasn’t reserved in the first place.
Sourcefn recognize_personhood(
who: PersonalId,
maybe_key: Option<Self::Member>,
) -> Result<(), DispatchError>
fn recognize_personhood( who: PersonalId, maybe_key: Option<Self::Member>, ) -> Result<(), DispatchError>
Recognized a person.
The personal id must be reserved or the person must have already been recognized and suspended in the past. If recognizing a new person, a key must be provided. If resuming the personhood then no key must be provided.
An error is returned if:
maybe_key
is some and the personal id was not reserved or is used by a recognized or suspended person.maybe_key
is none and the personal id was not recognized before.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.