Skip to main content

BaseHab

Struct BaseHab 

Source
pub struct BaseHab<'a> {
    pub db: Arc<Baser>,
    pub mgr: &'a mut Manager,
    pub rtr: Option<Arc<Router>>,
    pub rvy: &'a mut Revery,
    pub kvy: &'a mut Kevery,
    pub psr: &'a mut Parser<Empty>,
    pub name: String,
    pub ns: Option<String>,
    pub pre: Option<String>,
    pub temp: bool,
    pub inited: bool,
    pub delpre: Option<String>,
}
Expand description

A view of one local identifier over components owned by a Habery.

BaseHab borrows the shared Manager, Kevery, Revery and Parser for as long as it lives, so every Hab sees the same key state and local-prefix set. Get one from Habery::hab_by_name / hab_by_pre / make_hab; drop it to use the Habery again.

Fields§

§db: Arc<Baser>§mgr: &'a mut Manager§rtr: Option<Arc<Router>>§rvy: &'a mut Revery§kvy: &'a mut Kevery§psr: &'a mut Parser<Empty>§name: String§ns: Option<String>§pre: Option<String>§temp: bool§inited: bool§delpre: Option<String>

Implementations§

Source§

impl<'a> BaseHab<'a>

Source

pub fn new( db: Arc<Baser>, mgr: &'a mut Manager, rtr: Option<Arc<Router>>, rvy: &'a mut Revery, kvy: &'a mut Kevery, psr: &'a mut Parser<Empty>, name: String, ns: Option<String>, pre: Option<String>, temp: bool, ) -> Result<Self, KERIError>

Source

pub fn ingest_local(&mut self, msg: &[u8]) -> Result<(), KERIError>

Parse msg and route each message into this Hab’s Kevery/Revery as a local (protected) source, e.g. to store a receipt this Hab just made.

Source

pub fn make( &mut self, d_n_d: Option<bool>, code: Option<&str>, data: Option<Vec<SadValue>>, delpre: Option<String>, est_only: Option<bool>, isith: Option<Tholder>, verfers: Vec<Verfer>, nsith: Option<Tholder>, digers: Option<Vec<Diger>>, toad: Option<u32>, wits: Option<Vec<String>>, ) -> Result<SerderKERI, KERIError>

Create inception event with verifiers, threshold settings, witnesses, etc.

Source

pub fn save(&mut self, habord: &HabitatRecord) -> Result<(), KERIError>

Source

pub fn reconfigure(&self)

Source

pub fn iserder(&self) -> Result<SerderKERI, KERIError>

Get own inception event serder

Source

pub fn kevers(&self) -> &HashMap<String, Kever>

Get all kevers from the local database

Source

pub fn accepted(&self) -> bool

Check if this habitat is accepted into local KEL

Source

pub fn kever(&self) -> Result<&Kever, KERIError>

Get the kever (key state) of the local controller

Source

pub fn prefixes(&self) -> IndexSet<String>

Get local prefixes for database

Source

pub fn incept( &mut self, transferable: Option<bool>, code: Option<&str>, count: Option<u32>, ncount: Option<u32>, isith: Option<Tholder>, nsith: Option<Tholder>, toad: Option<u32>, wits: Option<Vec<String>>, cnfg: Option<Vec<&str>>, data: Option<Vec<SadValue>>, delpre: Option<String>, ) -> Result<SerderKERI, KERIError>

Create inception event (alias for make)

Source

pub fn rotate( &mut self, verfers: Option<Vec<Verfer>>, digers: Option<Vec<Diger>>, ncount: Option<u32>, isith: Option<Tholder>, nsith: Option<Tholder>, toad: Option<u32>, cuts: Option<Vec<String>>, adds: Option<Vec<String>>, data: Option<Vec<SadValue>>, ) -> Result<Vec<u8>, KERIError>

Perform rotation operation

Source

pub fn interact( &mut self, data: Option<Vec<SadValue>>, ) -> Result<Vec<u8>, KERIError>

Create, sign and accept an interaction event (keripy Hab.interact).

data is the event’s anchor list a, typically seals such as {"i": pre, "s": sn, "d": said}; None gives an empty list.

Source

pub fn sign( &self, ser: &[u8], verfers: Option<Vec<Verfer>>, indexed: Option<bool>, indices: Option<Vec<u32>>, ondices: Option<Vec<Option<u32>>>, ponly: Option<bool>, ) -> Result<Vec<Siger>, KERIError>

Sign given serialization using appropriate keys

Source

pub fn decrypt( &self, ser: &[u8], verfers: Option<Vec<Verfer>>, ) -> Result<Vec<u8>, KERIError>

Source

pub fn query( &self, pre: &str, src: &str, query: Option<IndexMap<String, SadValue>>, route: Option<String>, reply_route: Option<String>, stamp: Option<String>, ) -> Result<Vec<u8>, KERIError>

Source

pub fn endorse( &self, serder: &SerderKERI, last: Option<bool>, pipelined: Option<bool>, ) -> Result<Vec<u8>, KERIError>

Source

pub fn forward( &self, recipient: &str, topic: &str, msg: &[u8], mbx: &str, ) -> Result<Vec<u8>, KERIError>

Envelope msg (a KERI message with its attachments) for recipient’s mailbox at witness mbx, as keripy’s Poster.forwardToWitness does: this identifier’s KEL when mbx is not one of its own witnesses (keripy forwarding.introduce, which also skips it once mbx has receipted our inception), then a /fwd exn with msg embedded at /e/evt, endorsed by this identifier, then msg’s attachments as a pathed group. POST the result to mbx.

The mailbox stores msg under {recipient}/{topic}; the recipient’s keripy agent processes mailbox messages as local.

Source

pub fn receipt(&mut self, serder: &SerderKERI) -> Result<Vec<u8>, KERIError>

Create and process a receipt event for the given serder

Creates a KERI receipt event for the provided event serder, signs it with the appropriate signature type based on transferability, and processes it into the local database.

§Arguments
  • serder - The event serder to create a receipt for
§Returns
  • Result<Vec<u8>, KERIError> - The complete receipt message bytes
§Errors
  • KERIError::ValidationError - If receipt building, signing, or processing fails
  • KERIError::ConfigurationError - If habitat not properly initialized
  • KERIError::MissingEntryError - If required kever state is missing
Source

pub fn witness(&mut self, serder: &SerderKERI) -> Result<Vec<u8>, KERIError>

Source

pub fn replay( &self, pre: Option<&str>, fn_num: Option<u64>, ) -> Result<Vec<u8>, KERIError>

Replay events for the given prefix starting from the specified first seen number.

This method creates a complete replay by first including the delegation chain (if the identifier is delegated), then including all events for the prefix starting from the specified first seen ordinal number.

§Parameters
  • pre - Optional identifier prefix as string. If None, uses self.pre
  • fn_num - Optional first seen number to start replay from. Default is 0
§Returns
  • Result<Vec<u8>, KERIError> - Concatenated messages representing the complete replay
Source

pub fn replay_all(&self) -> Result<Vec<u8>, KERIError>

Replay all events for all identifier prefixes in the database.

This method creates a complete replay of all events across all prefixes in first seen order with attachments. Useful for database synchronization and backup scenarios.

§Returns
  • Result<Vec<u8>, KERIError> - Concatenated messages representing all events
Source

pub fn make_other_event( &self, pre: impl AsRef<[u8]>, sn: u64, ) -> Result<Option<Vec<u8>>, KERIError>

Make other event message for given prefix and sequence number.

§Parameters
  • pre - The prefix identifier
  • sn - The sequence number
§Returns
  • Ok(Some(Vec<u8>)) - The event message bytes if found
  • Ok(None) - If prefix not in kevers
  • Err(KERIError) - If missing event or other error
Source

pub fn fetch_end( &self, cid: &str, role: &str, eid: &str, ) -> Result<Option<EndpointRecord>, KERIError>

Fetch endpoint record for given cid, role, and eid

§Parameters
  • cid - Controller identifier (qb64 prefix)
  • role - Role such as watcher, witness
  • eid - Endpoint identifier
§Returns
  • Ok(Some(EndpointRecord)) - If record found
  • Ok(None) - If no record found
  • Err(KERIError) - On database error
Source

pub fn fetch_loc( &self, eid: &str, scheme: Option<&str>, ) -> Result<Option<LocationRecord>, KERIError>

Fetch location record for given eid and scheme

§Parameters
  • eid - Endpoint identifier
  • scheme - URL protocol scheme (defaults to “http”)
§Returns
  • Ok(Some(LocationRecord)) - If record found
  • Ok(None) - If no record found
  • Err(KERIError) - On database error
Source

pub fn fetch_end_allowed( &self, cid: &str, role: &str, eid: &str, ) -> Result<Option<bool>, KERIError>

Fetch endpoint allowed status for given cid, role, and eid

§Parameters
  • cid - Controller identifier (qb64 prefix)
  • role - Role such as watcher, witness
  • eid - Endpoint identifier
§Returns
  • Ok(Some(bool)) - If record found and allowed status is set
  • Ok(None) - If no record found or allowed status is None
  • Err(KERIError) - On database error
Source

pub fn fetch_end_enabled( &self, cid: &str, role: &str, eid: &str, ) -> Result<Option<bool>, KERIError>

Fetch endpoint enabled status for given cid, role, and eid

§Parameters
  • cid - Controller identifier (qb64 prefix)
  • role - Role such as watcher, witness
  • eid - Endpoint identifier
§Returns
  • Ok(Some(bool)) - If record found and enabled status is set
  • Ok(None) - If no record found or enabled status is None
  • Err(KERIError) - On database error
Source

pub fn fetch_end_authzed( &self, cid: &str, role: &str, eid: &str, ) -> Result<Option<bool>, KERIError>

Fetch endpoint authorization status (enabled OR allowed) for given cid, role, and eid

§Parameters
  • cid - Controller identifier (qb64 prefix)
  • role - Role such as watcher, witness
  • eid - Endpoint identifier
§Returns
  • Ok(Some(bool)) - If record found and either enabled or allowed is true
  • Ok(None) - If no record found or both enabled and allowed are None/false
  • Err(KERIError) - On database error
Source

pub fn fetch_url( &self, eid: &str, scheme: Option<&str>, ) -> Result<Option<String>, KERIError>

Fetch URL for given eid and scheme

§Parameters
  • eid - Endpoint identifier
  • scheme - URL protocol scheme (defaults to “http”)
§Returns
  • Ok(Some(String)) - If location record found, returns the URL
  • Ok(None) - If no location record found
  • Err(KERIError) - On database error
Source

pub fn fetch_urls( &self, eid: &str, scheme: Option<&str>, ) -> Result<Mict<String, String>, KERIError>

Fetch URLs for given eid and optional scheme filter Returns a Mict containing (scheme, url) pairs for all matching locations

§Parameters
  • eid - Endpoint identifier
  • scheme - Optional scheme filter (empty string means all schemes)
§Returns
  • Ok(Mict<String, String>) - Mict containing scheme->url mappings
  • Err(KERIError) - On database error
Source

pub fn fetch_role_urls( &self, cid: &str, role: Option<&str>, scheme: Option<&str>, eids: Option<&[String]>, enabled: bool, allowed: bool, ) -> Result<Mict<String, Mict<String, Mict<String, String>>>, KERIError>

Fetch role URLs for given cid, role, and optional filters Returns a Mict containing role -> Mict(eid -> urls) mappings

§Parameters
  • cid - Controller identifier
  • role - Optional role filter (empty string means all roles)
  • scheme - Optional scheme filter (empty string means all schemes)
  • eids - Optional list of endpoint identifiers to filter by
  • enabled - Whether to include enabled endpoints
  • allowed - Whether to include allowed endpoints
§Returns
  • Ok(Mict<String, Mict<String, Mict<String, String>>>) - Nested Mict structure
  • Err(KERIError) - On database error
Source

pub fn fetch_witness_urls( &self, cid: &str, scheme: Option<&str>, eids: Option<&[String]>, enabled: bool, allowed: bool, ) -> Result<Mict<String, Mict<String, Mict<String, String>>>, KERIError>

Fetch witness URLs for given cid Convenience method that calls fetch_role_urls with witness role

§Parameters
  • cid - Controller identifier
  • scheme - Optional scheme filter (empty string means all schemes)
  • eids - Optional list of endpoint identifiers to filter by
  • enabled - Whether to include enabled endpoints
  • allowed - Whether to include allowed endpoints
§Returns
  • Ok(Mict<String, Mict<String, Mict<String, String>>>) - Nested Mict structure
  • Err(KERIError) - On database error
Source

pub fn ends_for( &self, pre: &str, ) -> Result<HashMap<String, HashMap<String, HashMap<String, String>>>, KERIError>

Get all endpoints for a given prefix, organized by role and endpoint ID Returns a nested HashMap structure: role -> eid -> scheme -> url

§Parameters
  • pre - Prefix (controller identifier)
§Returns
  • Ok(HashMap<String, HashMap<String, HashMap<String, String>>>) - Nested structure of endpoints
  • Err(KERIError) - On database error
Source

pub fn reply( &self, route: String, data: Option<IndexMap<String, SadValue>>, stamp: Option<String>, version: Option<String>, kind: Option<String>, last: Option<bool>, pipelined: Option<bool>, ) -> Result<Vec<u8>, KERIError>

Create and endorse a reply event

§Parameters
  • route - Namespaced path that indicates data flow handler
  • data - Optional attribute section of reply
  • stamp - Optional timestamp (RFC-3339 format)
  • version - Optional version string
  • kind - Optional serialization kind
  • last - Optional flag for seal type (default: false)
  • pipelined - Optional flag for message format (default: true)
§Returns
  • Ok(Vec<u8>) - Endorsed reply message
  • Err(KERIError) - On validation or signing error
Source

pub fn make_end_role( &self, eid: String, role: Option<Roles>, allow: Option<bool>, stamp: Option<String>, ) -> Result<Vec<u8>, KERIError>

Create and endorse an endpoint role management reply event

§Parameters
  • eid - Endpoint identifier
  • role - Role to assign (default: Controller)
  • allow - If true, adds the role; if false, removes it (default: true)
  • stamp - Optional timestamp (RFC-3339 format)
§Returns
  • Ok(Vec<u8>) - Endorsed endpoint role reply message
  • Err(KERIError) - On validation or signing error
Source

pub fn load_end_role( &self, cid: &str, eid: &str, role: Option<Roles>, ) -> Result<Vec<u8>, KERIError>

Load and reconstruct an endpoint role message from the database

§Parameters
  • cid - Controller identifier
  • eid - Endpoint identifier
  • role - Role to load (default: Controller)
§Returns
  • Ok(Vec<u8>) - Reconstructed message bytes
  • Err(KERIError) - On database error or validation failure
Source

pub fn make_loc_scheme( &self, url: String, eid: Option<String>, scheme: Option<String>, stamp: Option<String>, ) -> Result<Vec<u8>, KERIError>

Create and endorse a location scheme reply message

§Parameters
  • url - The URL for this location scheme
  • eid - Optional endpoint identifier (defaults to self.pre)
  • scheme - Scheme type (default: “http”)
  • stamp - Optional timestamp (RFC-3339 format)
§Returns
  • Ok(Vec<u8>) - Endorsed location scheme reply message
  • Err(KERIError) - On validation or signing error
Source

pub fn reply_loc_scheme( &self, eid: String, scheme: Option<String>, ) -> Result<Vec<u8>, KERIError>

Create reply messages for all location schemes matching the given eid and scheme

§Parameters
  • eid - Endpoint identifier
  • scheme - Optional scheme filter (empty string means all schemes)
§Returns
  • Ok(Vec<u8>) - Combined reply messages for all matching location schemes
  • Err(KERIError) - On database error or message creation failure
Source

pub fn load_loc_scheme( &self, eid: &str, scheme: Option<&str>, ) -> Result<Vec<u8>, KERIError>

Load and reconstruct location scheme messages from the database

§Parameters
  • eid - Endpoint identifier
  • scheme - Optional scheme filter (None means all schemes)
§Returns
  • Ok(Vec<u8>) - Reconstructed message bytes
  • Err(KERIError) - On database error or validation failure
Source

pub fn reply_end_role( &self, cid: &str, role: Option<Roles>, eids: Option<&[String]>, scheme: Option<&str>, ) -> Result<Vec<u8>, KERIError>

Reply with endpoint role information for a given controller identifier

§Parameters
  • cid - Controller identifier
  • role - Optional role filter (None means all roles)
  • eids - Optional list of endpoint identifiers to filter by
  • scheme - Scheme filter for location queries (empty string means all schemes)
§Returns
  • Ok(Vec<u8>) - Combined reply messages
  • Err(KERIError) - On database error or validation failure
Source

pub fn reply_to_oobi( &self, aid: &str, role: Roles, eids: Option<&[String]>, ) -> Result<Vec<u8>, KERIError>

Reply to OOBI (Out-Of-Band Introduction) request This is a simple wrapper around reply_end_role

§Parameters
  • aid - Agent identifier (controller ID)
  • role - Role to reply with
  • eids - Optional list of endpoint identifiers to filter by
§Returns
  • Ok(Vec<u8>) - Combined reply messages
  • Err(KERIError) - On database error or validation failure
Source

pub fn get_own_event<T>( &self, sn: u64, allow_partially_signed: bool, ) -> Result<(SerderKERI, Vec<Siger>, Option<T>), KERIError>
where T: TryFrom<Vec<u8>>, <T as TryFrom<Vec<u8>>>::Error: Debug,

Get own event at specified sequence number

§Parameters
  • sn - Sequence number of the event to retrieve
  • allow_partially_signed - If true, also check partially signed events database
§Returns
  • Ok((SerderKERI, Vec<Siger>, Option<T>)) - Event serder, signatures, and optional couple
  • Err(KERIError) - On missing event or database error
Source

pub fn make_own_event( &self, sn: u64, allow_partially_signed: bool, ) -> Result<Vec<u8>, KERIError>

Create own event message with attachments at specified sequence number

§Parameters
  • sn - Sequence number of the event to retrieve
  • allow_partially_signed - If true, also check partially signed events database
§Returns
  • Ok(Vec<u8>) - Complete event message with attachments
  • Err(KERIError) - On missing event or database error
Source

pub fn witness_receipt_msgs( &self, sn: u64, ) -> Result<Vec<(String, Vec<u8>)>, KERIError>

Messages that give every witness of own event sn the receipts of the other witnesses (the second half of keripy Receiptor.receipt).

For each witness, the message is a rct for the event with the other witnesses’ signatures stored so far as receipt couples. For an inception, and for a rotation toward a witness it adds, the other witnesses’ /loc/scheme replies come first so the witnesses learn each other’s endpoints. A witness with nothing to receive is skipped.

Returns (witness prefix, CESR stream) pairs.

Source

pub fn make_own_inception( &self, allow_partially_signed: bool, ) -> Result<Vec<u8>, KERIError>

Create own inception event message with attachments This is a convenience method that calls make_own_event with sn=0

§Parameters
  • allow_partially_signed - If true, also check partially signed events database
§Returns
  • Ok(Vec<u8>) - Complete inception event message with attachments
  • Err(KERIError) - On missing event or database error
Source

pub fn process_cues( &mut self, cues: &mut VecDeque<IndexMap<String, SadValue>>, ) -> Result<Vec<u8>, KERIError>

Process all cues and return combined messages

§Parameters
  • cues - Deque of cue objects to process
§Returns
  • Ok(Vec<u8>) - Combined outgoing messages from all cues
  • Err(KERIError) - On processing error
Source

pub fn process_cues_iter( &mut self, cues: &mut VecDeque<IndexMap<String, SadValue>>, ) -> Result<Vec<Result<Vec<u8>, KERIError>>, KERIError>

Process cues iteratively, yielding messages for each cue

§Parameters
  • cues - Deque of cue objects to process
§Returns
  • Ok(Vec<Result<Vec<u8>, KERIError>>) - Iterator of message results
  • Err(KERIError) - On processing error
Source

pub fn witnesser(&self) -> bool

Returns whether this habitat can act as a witness

§Returns
  • bool - Always true for base implementation

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for BaseHab<'a>

§

impl<'a> !UnwindSafe for BaseHab<'a>

§

impl<'a> Freeze for BaseHab<'a>

§

impl<'a> Send for BaseHab<'a>

§

impl<'a> Sync for BaseHab<'a>

§

impl<'a> Unpin for BaseHab<'a>

§

impl<'a> UnsafeUnpin for BaseHab<'a>

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> 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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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