Struct taple_core::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_pending_requests( &self ) -> Result<Vec<ApprovalEntity>, ApiError>

It allows to obtain all the voting requests pending to be resolved in the node. These requests are received from other nodes in the network when they try to update a governance subject. It is necessary to vote their agreement or disagreement with the proposed changes in order for the events to be implemented.

Possible errors

• [ApiError::InternalError] if an internal error occurs during operation execution.

source

pub async fn get_single_request( &self, id: DigestIdentifier ) -> Result<ApprovalEntity, ApiError>

It allows to obtain a single voting request pending to be resolved in the node. This request is received from other nodes in the network when they try to update a governance subject. It is necessary to vote its agreement or disagreement with the proposed changes in order for the events to be implemented.

Possible errors

• [ApiError::InternalError] if an internal error occurs during operation execution. • ApiError::NotFound if the requested request does not exist.

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 approval_request( &self, request_id: DigestIdentifier, acceptance: bool ) -> Result<ApprovalEntity, ApiError>

Allows to vote on a voting request that previously exists in the system. This vote will be sent to the corresponding node in charge of its collection.

Possible errors

• [ApiError::InternalError] if an internal error occurs during operation execution.
ApiError::NotFound if the request does not exist in the system.
ApiError::InvalidParameters if the specified request identifier does not match a valid DigestIdentifier.
ApiError::VoteNotNeeded if the node’s vote is no longer required.
This occurs when the acceptance of the changes proposed by the petition has already been resolved by the rest of the nodes in the network or when the node cannot participate in the voting process because it lacks the voting role.

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>

source

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

source

pub async fn get_approvals( &self, state: Option<ApprovalState>, from: Option<String>, quantity: Option<i64> ) -> Result<Vec<ApprovalEntity>, 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 !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 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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