Skip to main content

Session

Struct Session 

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

Owned guard over one beekeeper session.

Sessions don’t own the underlying C++ state — they share it with the parent BeekeeperApi (and with any wallet handles), so multiple sessions can be alive at once. Dropping the guard closes the session; there is no explicit close call.

Implementations§

Source§

impl Session

Source

pub fn is_temporary(self, is_temporary: bool) -> Self

Builder-style override for the is_temporary flag applied by create_wallet.

When never called, wallets default to temporary if and only if the beekeeper was opened with BeekeeperOptions::in_memory.

let session = bk.create_session().unwrap().is_temporary(true);
let created = session.create_wallet("scratch", "password").unwrap();
Source

pub fn get_info(&self) -> SessionInfo

Capture a SessionInfo snapshot.

Does not mutate the activity clock.

Source

pub fn has_wallet(&self, name: &str) -> Result<bool, BeekeeperError>

true when a wallet with the given name exists in the underlying wallet manager.

The check is process-wide, not session-scoped: any wallet known to the wallet manager counts, whether or not this session opened it.

Source

pub fn list_wallets(&self) -> Result<Vec<WalletInfo>, BeekeeperError>

All wallets currently opened in this session (locked or unlocked), enriched with their is_temporary flag.

Source

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

All wallets present on disk, opened or not.

Each entry is reported as unlocked: false; the is_temporary flag is filled in from this session’s metadata if the wallet was created or opened through this session in the past, otherwise defaults to false.

In in-memory mode this returns an empty vector.

Source

pub fn create_wallet<'p>( &self, name: &str, password: impl Into<Option<&'p str>>, ) -> Result<CreatedWallet, BeekeeperError>

Create a brand-new wallet and return it as a CreatedWallet.

password accepts anything convertible into Option<&str> — pass a &str directly, or None to have the C++ side generate a random password, returned in the CreatedWallet::password field.

Whether the wallet is temporary is controlled by the is_temporary builder; unset, it defaults to the beekeeper-wide BeekeeperOptions::in_memory flag.

Source

pub fn open_wallet(&self, name: &str) -> Result<LockedWallet, BeekeeperError>

Open an existing wallet and return its LockedWallet handle.

The wallet is registered with is_temporary: false because previously-persisted wallets are by definition non-temporary. Opening an already-open wallet is a no-op.

Source

pub fn close_wallet(&self, name: &str) -> Result<(), BeekeeperError>

Close name on the C++ side and drop its metadata entry.

This does not lock the wallet first — call UnlockedWallet::lock yourself if the wallet is unlocked. The higher-level LockedWallet::close and UnlockedWallet::close methods do the right thing automatically.

Source

pub fn lock_all(&self) -> Result<Vec<WalletInfo>, BeekeeperError>

Lock every unlocked wallet in this session and return the resulting (post-lock) wallet listing, with every unlocked field false.

Wallets opened via a different handle of the same session are also locked.

Trait Implementations§

Source§

impl Drop for Session

Locks everything in the session, then closes the session itself.

Errors are ignored: the session may already have been closed by BeekeeperApi::delete, in which case this is a no-op.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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> 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.