pub struct AccountBuilder<C = Arc<Client>>where
    C: SharedPtr<Client>,{ /* private fields */ }
Expand description

An Account builder for easy account configuration.

To reduce memory usage, accounts created from the same builder share the same Storage used to store identities, and the same Client used to publish identities to the Tangle.

The configuration on the other hand is cloned, and therefore unique for each built account. This means a builder can be reconfigured in-between account creations, without affecting the configuration of previously built accounts.

Implementations§

source§

impl<C> AccountBuilder<C>where C: SharedPtr<Client>,

source

pub fn new() -> Self

Creates a new AccountBuilder.

source

pub fn autosave(self, value: AutoSave) -> Self

Sets the account auto-save behaviour.

source

pub fn autopublish(self, value: bool) -> Self

Sets the account auto-publish behaviour.

source

pub fn storage<S: Storage + 'static>(self, value: S) -> Self

Sets the account storage adapter.

source

pub fn storage_shared(self, value: Arc<dyn Storage>) -> Self

Sets the account storage adapter from a shared pointer.

source

pub fn client(self, client: C) -> Self

Sets the IOTA Tangle Client, this determines the Network used by the identity. Accounts created by the same AccountBuilder will share the same Client.

NOTE: this overwrites any ClientBuilder previously set by AccountBuilder::client_builder.

source

pub fn client_builder(self, client_builder: ClientBuilder) -> Self

Sets the IOTA Tangle Client, this determines the Network used by the identity. Accounts created by the same AccountBuilder will share the same Client.

NOTE: this overwrites any Client previously set by AccountBuilder::client.

source

pub async fn create_identity( &mut self, input: IdentitySetup ) -> Result<Account<C>>

Creates a new identity based on the builder configuration and returns an Account instance to manage it.

The identity is stored locally in the Storage. The DID network is automatically determined by the Client used to publish it.

See IdentitySetup to customize the identity creation.

source

pub async fn load_identity(&mut self, did: IotaDID) -> Result<Account<C>>

Loads an existing identity with the specified did using the current builder configuration. The identity must exist in the configured Storage.

Warning

Callers are expected not to load the same IotaDID into more than one account, as that would cause race conditions when updating the identity.

Trait Implementations§

source§

impl<C> Debug for AccountBuilder<C>where C: SharedPtr<Client> + Debug,

source§

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

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

impl<C> Default for AccountBuilder<C>where C: SharedPtr<Client>,

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<C = Arc<Client, Global>> !RefUnwindSafe for AccountBuilder<C>

§

impl<C> Send for AccountBuilder<C>where C: Send,

§

impl<C> Sync for AccountBuilder<C>where C: Sync,

§

impl<C> Unpin for AccountBuilder<C>where C: Unpin,

§

impl<C = Arc<Client, Global>> !UnwindSafe for AccountBuilder<C>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> Instrument for T

source§

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

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

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

§

type Output = T

Should always be Self
source§

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

§

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 Twhere U: TryFrom<T>,

§

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 Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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