ClearanceRegistry

Struct ClearanceRegistry 

Source
pub struct ClearanceRegistry { /* private fields */ }
Expand description

Maps daemon names to identities with O(1) pubkey lookups via reverse index.

Implementations§

Source§

impl ClearanceRegistry

Source

pub fn new() -> Self

Source

pub fn register(&mut self, name: String, pubkey: [u8; 32], level: SecurityLevel)

Register a daemon with its initial pubkey and clearance level. Generation starts at 0. Overwrites any existing registration for this name.

Source

pub fn register_with_generation( &mut self, name: String, pubkey: [u8; 32], level: SecurityLevel, generation: u64, )

Register with an explicit generation (used after revoke-then-reregister).

Source

pub fn lookup(&self, pubkey: &[u8; 32]) -> Option<&DaemonIdentity>

Look up a daemon identity by pubkey. O(1) via reverse index. Returns None for unregistered keys (ephemeral CLI clients).

Source

pub fn lookup_name(&self, pubkey: &[u8; 32]) -> Option<&str>

Look up the daemon name for a pubkey. O(1) via reverse index.

Source

pub fn find_by_name(&self, name: &str) -> Option<&DaemonIdentity>

Find a daemon identity by name. O(1). Always deterministic.

Source

pub fn register_pending( &mut self, daemon_name: &str, new_pubkey: [u8; 32], ) -> bool

Register a pending rotation pubkey for an existing daemon.

Both old (current) and new (pending) pubkeys are valid for identity resolution during the grace period. The pending key gets the same security_level and generation as the current identity — register_pending does NOT accept these as parameters to prevent accidental clearance changes.

If a pending key already exists (double rotation without finalize), the old pending key is removed from the index and replaced.

Returns true if the daemon was found and the pending key was registered. Returns false if no daemon with that name exists.

Source

pub fn finalize_rotation(&mut self, daemon_name: &str) -> bool

Finalize rotation: promote pending to current, remove old from index, increment generation.

Returns true if the daemon was found and had a pending key to finalize. Returns false if the daemon doesn’t exist or has no pending key.

Source

pub fn revoke_by_name(&mut self, daemon_name: &str) -> Option<DaemonIdentity>

Revoke a daemon entirely: remove identity and all pubkey index entries.

Handles the dual-key case atomically: removes both current and pending pubkeys from the reverse index in one operation.

Returns the removed identity (for generation continuity) or None.

Source

pub fn snapshot_generations(&self) -> HashMap<String, u64>

Snapshot all daemon generations. Used by rotation phase 1 baseline.

Trait Implementations§

Source§

impl Clone for ClearanceRegistry

Source§

fn clone(&self) -> ClearanceRegistry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClearanceRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ClearanceRegistry

Source§

fn default() -> ClearanceRegistry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more