Struct identity_account::account::Account
source · [−]Expand description
An account manages one identity.
It handles private keys, writing to storage and publishing to the Tangle.
Implementations
sourceimpl<C> Account<C> where
C: SharedPtr<Client>,
impl<C> Account<C> where
C: SharedPtr<Client>,
sourcepub fn builder() -> AccountBuilder<C>
pub fn builder() -> AccountBuilder<C>
Creates a new AccountBuilder.
sourcepub fn storage(&self) -> &Arc<dyn Storage>
pub fn storage(&self) -> &Arc<dyn Storage>
Returns a reference counter to the Storage implementation.
sourcepub fn autopublish(&self) -> bool
pub fn autopublish(&self) -> bool
Returns whether auto-publish is enabled.
sourcepub fn chain_state(&self) -> &ChainState
pub fn chain_state(&self) -> &ChainState
Return the chain state of the identity.
sourcepub fn document(&self) -> &IotaDocument
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.
sourcepub fn set_chain_state_unchecked(&mut self, chain_state: ChainState)
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!
sourcepub async fn resolve_identity(&self) -> Result<ResolvedIotaDocument>
pub async fn resolve_identity(&self) -> Result<ResolvedIotaDocument>
Resolves the DID Document associated with this Account
from the Tangle.
sourcepub fn update_identity(&mut self) -> IdentityUpdater<'_, C>
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.
sourcepub async fn update_document_unchecked(
&mut self,
document: IotaDocument
) -> Result<()>
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!
sourcepub async fn delete_identity(self) -> Result<()>
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!
sourcepub async fn sign<U>(
&self,
fragment: &str,
data: &mut U,
options: ProofOptions
) -> Result<()> where
U: Serialize + SetSignature,
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
.
sourcepub async fn publish(&mut self) -> Result<()>
pub async fn publish(&mut self) -> Result<()>
Push all unpublished changes to the tangle in a single message.
sourcepub async fn publish_with_options(
&mut self,
options: PublishOptions
) -> Result<()>
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
.
sourcepub async fn fetch_document(&mut self) -> Result<()>
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.
sourcepub async fn revoke_credentials(
&mut self,
fragment: &str,
credential_indices: &[u32]
) -> Result<()>
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
.
sourcepub async fn unrevoke_credentials(
&mut self,
fragment: &str,
credential_indices: &[u32]
) -> Result<()>
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
.
sourcepub async fn encrypt_data(
&self,
plaintext: &[u8],
associated_data: &[u8],
encryption_algorithm: &EncryptionAlgorithm,
cek_algorithm: &CekAlgorithm,
public_key: PublicKey
) -> Result<EncryptedData>
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.
sourcepub async fn decrypt_data(
&self,
data: EncryptedData,
encryption_algorithm: &EncryptionAlgorithm,
cek_algorithm: &CekAlgorithm,
fragment: &str
) -> Result<Vec<u8>>
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
Auto Trait Implementations
impl<C = Arc<Client>> !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>> !UnwindSafe for Account<C>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more