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

An account manages one identity.

It handles private keys, writing to storage and publishing to the Tangle.

Implementations§

source§

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

source

pub fn builder() -> AccountBuilder<C>

Creates a new AccountBuilder.

source

pub fn storage(&self) -> &Arc<dyn Storage>

Returns a reference counter to the Storage implementation.

source

pub fn autopublish(&self) -> bool

Returns whether auto-publish is enabled.

source

pub fn autosave(&self) -> AutoSave

Returns the auto-save configuration value.

source

pub fn actions(&self) -> usize

Returns the total number of actions executed by this instance.

source

pub fn did(&self) -> &IotaDID

Returns the did of the managed identity.

source

pub fn chain_state(&self) -> &ChainState

Return the chain state of the identity.

source

pub fn document(&self) -> &IotaDocument

Returns the DID document of the identity, which this account manages, with all updates applied.

Note: the returned document only has a valid signature after publishing an integration chain update. In general, for use cases where the signature is required, it is advisable to resolve the document from the Tangle.

source

pub fn set_chain_state_unchecked(&mut self, chain_state: ChainState)

Sets the ChainState for the identity this account manages, without doing any validation.

WARNING

This method is dangerous and can easily corrupt the internal state, potentially making the identity unusable. Only call this if you fully understand the implications!

source

pub async fn resolve_identity(&self) -> Result<ResolvedIotaDocument>

Resolves the DID Document associated with this Account from the Tangle.

source

pub fn update_identity(&mut self) -> IdentityUpdater<'_, C>

Returns the IdentityUpdater for this identity.

On this type, various operations can be executed that modify an identity, such as creating services or methods.

source

pub async fn update_document_unchecked( &mut self, document: IotaDocument ) -> Result<()>

Overwrites the IotaDocument this account manages, without doing any validation.

WARNING

This method is dangerous and can easily corrupt the internal state, potentially making the identity unusable. Only call this if you fully understand the implications!

source

pub async fn delete_identity(self) -> Result<()>

Removes the identity from the local storage entirely.

Note: This will remove all associated document updates and key material - recovery is NOT POSSIBLE!

source

pub async fn sign<U>( &self, fragment: &str, data: &mut U, options: ProofOptions ) -> Result<()>where U: Serialize + SetSignature,

Signs data with the key specified by fragment.

source

pub async fn publish(&mut self) -> Result<()>

Push all unpublished changes to the tangle in a single message.

source

pub async fn publish_with_options( &mut self, options: PublishOptions ) -> Result<()>

Push all unpublished changes to the Tangle in a single message, optionally choosing the signing key used or forcing an integration chain update.

See PublishOptions.

source

pub async fn fetch_document(&mut self) -> Result<()>

Fetches the latest document from the tangle and overwrites the local document.

If a DID is managed from distributed accounts, this should be called before making changes to the identity, to avoid publishing updates that would be ignored.

source

pub async fn revoke_credentials( &mut self, fragment: &str, credential_indices: &[u32] ) -> Result<()>

If the document has a RevocationBitmap service identified by fragment, revoke all credentials with a revocationBitmapIndex in credential_indices.

source

pub async fn unrevoke_credentials( &mut self, fragment: &str, credential_indices: &[u32] ) -> Result<()>

If the document has a RevocationBitmap service identified by fragment, unrevoke all credentials with a revocationBitmapIndex in credential_indices.

source

pub async fn encrypt_data( &self, plaintext: &[u8], associated_data: &[u8], encryption_algorithm: &EncryptionAlgorithm, cek_algorithm: &CekAlgorithm, public_key: PublicKey ) -> Result<EncryptedData>

Encrypts the given plaintext with the specified encryption_algorithm and cek_algorithm.

Returns an EncryptedData instance.

source

pub async fn decrypt_data( &self, data: EncryptedData, encryption_algorithm: &EncryptionAlgorithm, cek_algorithm: &CekAlgorithm, fragment: &str ) -> Result<Vec<u8>>

Decrypts the given data with the key identified by fragment using the given encryption_algorithm and cek_algorithm.

Returns the decrypted text.

Trait Implementations§

source§

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

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<C = Arc<Client, Global>> !UnwindSafe for Account<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