Struct Api

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

Object that allows interaction with a TAPLE node.

It has methods to perform all available read and write operations.

Implementations§

Source§

impl Api

Source

pub fn new( peer_id: PeerId, controller_id: String, public_key: Vec<u8>, sender: SenderEnd<APICommands, ApiResponses>, ) -> Self

Source

pub fn peer_id(&self) -> &PeerId

Source

pub fn controller_id(&self) -> &String

Source

pub fn public_key(&self) -> &Vec<u8>

Source

pub async fn get_request( &self, request_id: DigestIdentifier, ) -> Result<TapleRequest, ApiError>

Source

pub async fn external_request( &self, event_request: Signed<EventRequest>, ) -> Result<DigestIdentifier, ApiError>

Allows to make a request to the node from an external Invoker

Source

pub async fn get_subjects( &self, namespace: String, from: Option<String>, quantity: Option<i64>, ) -> Result<Vec<SubjectData>, ApiError>

Allows to get all subjects that are known to the current node, regardless of their governance. Paging can be performed using the optional arguments from and quantity. Regarding the first one, note that it admits negative values, in which case the paging is performed in the opposite direction starting from the end of the collection. Note that this method also returns the subjects that model governance.

§Possible errors

• [ApiError::InternalError] if an internal error occurred during the execution of the operation.

Source

pub async fn get_subjects_by_governance( &self, governance_id: DigestIdentifier, from: Option<String>, quantity: Option<i64>, ) -> Result<Vec<SubjectData>, ApiError>

Source

pub async fn get_governances( &self, namespace: String, from: Option<String>, quantity: Option<i64>, ) -> Result<Vec<SubjectData>, ApiError>

It allows to obtain all the subjects that model existing governance in the node.

§Possible errors

• [ApiError::InternalError] if an internal error occurred during the execution of the operation.

Source

pub async fn get_event( &self, subject_id: DigestIdentifier, sn: u64, ) -> Result<Signed<Event>, ApiError>

Source

pub async fn get_events( &self, subject_id: DigestIdentifier, from: Option<i64>, quantity: Option<i64>, ) -> Result<Vec<Signed<Event>>, ApiError>

Allows to obtain events from a specific subject previously existing in the node. Paging can be performed by means of the optional arguments from and quantity. Regarding the former, it should be noted that negative values are allowed, in which case the paging is performed in the opposite direction starting from the end of the string.

§Possible errors

ApiError::InvalidParameters if the specified subject identifier does not match a valid DigestIdentifier.

Source

pub async fn get_subject( &self, subject_id: DigestIdentifier, ) -> Result<SubjectData, ApiError>

Allows to obtain a specified subject by specifying its identifier.

§Possible errors

ApiError::InvalidParameters if the specified identifier does not match a valid DigestIdentifier.
ApiError::NotFound if the subject does not exist.

Source

pub async fn add_preauthorize_subject( &self, subject_id: &DigestIdentifier, providers: &HashSet<KeyIdentifier>, ) -> Result<(), ApiError>

Source

pub async fn get_all_allowed_subjects_and_providers( &self, from: Option<String>, quantity: Option<i64>, ) -> Result<Vec<(DigestIdentifier, HashSet<KeyIdentifier>)>, ApiError>

Source

pub async fn add_keys( &self, derivator: KeyDerivator, ) -> Result<KeyIdentifier, ApiError>

Source

pub async fn get_validation_proof( &self, subject_id: DigestIdentifier, ) -> Result<(HashSet<Signature>, ValidationProof), ApiError>

Source

pub async fn get_governance_subjects( &self, governance_id: DigestIdentifier, from: Option<String>, quantity: Option<i64>, ) -> Result<Vec<SubjectData>, ApiError>

Trait Implementations§

Source§

impl Clone for Api

Source§

fn clone(&self) -> Api

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Api

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Api

§

impl RefUnwindSafe for Api

§

impl Send for Api

§

impl Sync for Api

§

impl Unpin for Api

§

impl UnwindSafe for Api

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T