[][src]Struct fabric_contract::contract::Ledger

pub struct Ledger {}

Ledger representing high level concept of the Fabric Blockchain network

Provides the access points for

When a transaction is invoked, it takes place under a 'transactional context' This context can be queried to provide the current transaction id, and information about the identity requesting the transaction.

All operations need to be done under this transactional context, therefore the context needs to be passed to obtain the Ledger instance

Example

This example is not tested
use fabric_contract::contract::*;


pub fn asset_exists(my_assset_id: String) -> Result<bool,String> {
   let ledger = Ledger::access_ledger();
    
   let world = ledger.get_collection(CollectionName::World);

   Ok(world.state_exists(&my_assset_id))

}

Implementations

impl Ledger[src]

pub fn access_ledger() -> Ledger[src]

Get the Ledger based on the current transactional context

The Tranasctional Context is available via the Transaction API

pub fn get_collection(&self, name: CollectionName) -> Collection[src]

Return the collection based on the name

The collection provides access to the put & get Fabric semantics of the underlying world state, or private data that is specified by the Collection name.

Example

This example is not tested
use fabric_contract::contract::*;
let ledger = Ledger::access_ledger();

// get the collectin that is backed by the World State
let world = ledger.get_collection(CollectionName::World);  

// get the collection that is backed by the Organization's Implicity Private Data Collection
let orgs_collection = ledger.get_collection(CollectionName::Organization(String::from("org1")));
    
// get the collection that is backed by the named Private Data Collection
let private_collection = ledger.get_collection(CollectionName::Private(String::from("my_private_details")));

Auto Trait Implementations

impl RefUnwindSafe for Ledger

impl Send for Ledger

impl Sync for Ledger

impl Unpin for Ledger

impl UnwindSafe for Ledger

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> From<T> for T[src]

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

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.