Skip to main content

BeekeeperApi

Struct BeekeeperApi 

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

Root handle for the Beekeeper wallet daemon.

A single BeekeeperApi owns one C++ wallet manager and zero or more sessions; each session in turn owns zero or more wallets.

Use BeekeeperApi::new to construct and create_session to obtain an owned Session guard for further work.

Implementations§

Source§

impl BeekeeperApi

Source

pub fn new(options: impl Into<Option<BeekeeperOptions>>) -> Self

Construct a new beekeeper instance.

Accepts anything convertible into Option<BeekeeperOptions>: pass a BeekeeperOptions value directly, or None to use BeekeeperOptions::default().

When the options are not in-memory this also creates <storage_root>/.beekeeper/ (if missing) for wallet files.

Source

pub fn create_session(&self) -> Result<Session, BeekeeperError>

Open a new session and return it as an owned Session guard.

The session closes itself (locking its wallets first) when dropped; there is no explicit close call.

Source

pub fn delete(&self) -> Result<(), BeekeeperError>

Close every session, flush storage, and shut the C++ holder down.

Named after the TS delete() API; there is no Rust destructor work behind it. Calling it is useful when you want the storage flushed deterministically before the process exits.

Any Session guard still alive is closed here; its later Drop becomes a no-op. After calling delete the C++ storage handle has been closed; further operations will fail.

Source

pub fn refresh_timeout(&self)

Reset the inactivity clock to now.

Used internally after every successful unlocked-wallet operation. Call manually only if you have some other notion of activity to keep the wallet alive.

Source

pub fn throw_if_timed_out_and_refresh(&self) -> Result<(), BeekeeperError>

If the inactivity timeout has elapsed, return BeekeeperError::TimedOut. Otherwise reset the clock.

Every UnlockedWallet operation calls this as its first step.

Source

pub fn is_timed_out(&self) -> bool

true if the inactivity timeout is enabled and has elapsed.

unlock_timeout == 0 permanently returns false.

Source

pub fn get_timeout_time(&self) -> SystemTime

Wall-clock instant at which the wallet will auto-lock.

When the timeout is disabled this returns a far-future sentinel: the UNIX epoch plus 100 years (≈ year 2069).

Source

pub fn list_created_wallets(&self) -> Vec<String>

Names of every wallet found in the storage directory.

Returns [] in in-memory mode, since there is nothing to scan. The names are derived from filenames by stripping the .wallet suffix; other files in the directory are ignored.

Source

pub fn version(&self) -> &'static str

The crate’s SemVer string (compiled-in CARGO_PKG_VERSION).

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.