[][src]Struct exonum_middleware_service::Batch

pub struct Batch {
    pub inner: Vec<AnyTx>,
}

Transactions executed in a batch.

Examples

Batch is a mutable stub, which adds corresponding transactions on call:

// Suppose we have this interface defined.
mod token {
    #[exonum_interface]
    pub trait Token<Ctx> {
        type Output;
        #[interface_method(id = 0)]
        fn create_wallet(&self, ctx: Ctx, owner: String) -> Self::Output;
        #[interface_method(id = 1)]
        fn burn(&self, ctx: Ctx, amount: u64) -> Self::Output;
        // Other methods...
    }
}

use exonum_middleware_service::{
    ArtifactReq, Batch, MiddlewareInterfaceMut, MiddlewareService,
};
use token::{Token, TokenMut};

const TOKEN_ID: InstanceId = 100;

let mut batch = Batch::new();
batch.create_wallet(TOKEN_ID, "Alice".into());
batch.burn(TOKEN_ID, 50);
// Batch can include calls to multiple services. Let's add
// a checked call to the token service, which will be routed
// through a default middleware service instance.
let req: ArtifactReq = "exonum.Token@1".parse().unwrap();
let checked_call = req.burn(TOKEN_ID, 20);
batch.checked_call(MiddlewareService::INSTANCE_ID, checked_call);
assert_eq!(batch.inner.len(), 3);

Fields

inner: Vec<AnyTx>

Transactions included in the batch.

Methods

impl Batch[src]

pub fn new() -> Self[src]

Creates an empty batch.

pub fn with_call(self, call: AnyTx) -> Self[src]

Appends a call into the batch.

Trait Implementations

impl BinaryValue for Batch[src]

impl Clone for Batch[src]

impl Debug for Batch[src]

impl Default for Batch[src]

impl<'de> Deserialize<'de> for Batch[src]

impl GenericCallMut<u32> for Batch[src]

type Output = ()

Type of values output by the stub.

impl ProtobufConvert for Batch[src]

type ProtoStruct = Batch

Type of the protobuf clone of Self

impl Serialize for Batch[src]

Auto Trait Implementations

impl RefUnwindSafe for Batch

impl Send for Batch

impl Sync for Batch

impl Unpin for Batch

impl UnwindSafe for Batch

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Clear for T where
    T: InitializableFromZeroed + ?Sized

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T> InitializableFromZeroed for T where
    T: Default

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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