Struct DamlCommandService

Source
pub struct DamlCommandService<'a> { /* private fields */ }
Expand description

Submit commands to a Daml ledger and await the completion.

The Command Service is able to correlate submitted commands with completion data, identify timeouts, and return contextual information with each tracking result. This supports the implementation of stateless clients.

Implementations§

Source§

impl<'a> DamlCommandService<'a>

Source

pub fn new( channel: Channel, ledger_id: &'a str, auth_token: Option<&'a str>, ) -> Self

Create a DamlCommandService for a given GRPC channel and ledger_id.

Source

pub fn with_token(self, auth_token: &'a str) -> Self

Override the JWT token to use for this service.

Source

pub fn with_ledger_id(self, ledger_id: &'a str) -> Self

Override the ledger id to use for this service.

Source

pub async fn submit_and_wait( &self, commands: impl Into<DamlCommands> + Debug, ) -> DamlResult<String>

Submits a composite DamlCommands and await the completion.

This method executes commands synchronously on the ledger server (unlike the DamlCommandSubmissionService which is executed asynchronously on the ledger server). This service only waits for the completion of the execution of the command, not the propagation of any resulting events which must be consumed via the DamlTransactionService.

Note that this method is executed asynchronously on the client side and so will immediately return a future which must be driven to completion before a result can be observed.

§Errors

Propagates communication failure errors as GrpcTransportError and Daml server failures as GRPCStatusError errors.

§Examples
let ledger_client = DamlGrpcClientBuilder::uri("http://127.0.0.1").connect().await?;
let future_command = ledger_client.command_service().submit_and_wait(commands).await;
match future_command {
    Ok(command_id) => assert_eq!("1234", command_id),
    Err(e) => panic!("submit_and_wait failed, error was {}", e.to_string()),
}
Source

pub async fn submit_and_wait_for_transaction_id( &self, commands: impl Into<DamlCommands> + Debug, ) -> DamlResult<(String, String)>

Submits a composite DamlCommands and returns the resulting transaction id.

DOCME fully document this TODO ugly API returning a tuple as completion_offset was recently added, refactor

Source

pub async fn submit_and_wait_for_transaction( &self, commands: impl Into<DamlCommands> + Debug, ) -> DamlResult<(DamlTransaction, String)>

Submits a composite DamlCommands and returns the resulting DamlTransaction.

DOCME fully document this TODO ugly API returning a tuple as completion_offset was recently added, refactor

Source

pub async fn submit_and_wait_for_transaction_tree( &self, commands: impl Into<DamlCommands> + Debug, ) -> DamlResult<(DamlTransactionTree, String)>

Submits a composite DamlCommands and returns the resulting DamlTransactionTree. DOCME fully document this TODO ugly API returning a tuple as completion_offset was recently added, refactor

Trait Implementations§

Source§

impl<'a> Debug for DamlCommandService<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for DamlCommandService<'a>

§

impl<'a> !RefUnwindSafe for DamlCommandService<'a>

§

impl<'a> Send for DamlCommandService<'a>

§

impl<'a> Sync for DamlCommandService<'a>

§

impl<'a> Unpin for DamlCommandService<'a>

§

impl<'a> !UnwindSafe for DamlCommandService<'a>

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

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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> 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