Struct BlockchainData

Source
pub struct BlockchainData<T> { /* private fields */ }
Expand description

Provides access to blockchain data for the executing service.

Implementations§

Source§

impl<T: RawAccess + AsReadonly> BlockchainData<T>

Source

pub fn new(access: T, instance_name: impl Into<String>) -> Self

Creates structured access to blockchain data based on the unstructured access (e.g., a Snapshot or a Fork) and the descriptor of the executing service.

Source

pub fn instance_name(&self) -> &str

Returns the instance name of the executing service.

Source

pub fn for_core(&self) -> CoreSchema<T::Readonly>

Returns core schema.

Source

pub fn for_dispatcher(&self) -> DispatcherSchema<T::Readonly>

Returns dispatcher schema.

Source

pub fn for_service<'q>( &self, id: impl Into<InstanceQuery<'q>>, ) -> Option<Prefixed<T::Readonly>>

Returns a mount point for another service. If the service with id does not exist, returns None.

§Safety

This method does not check the service type; the caller is responsible for constructing a schema of a correct type around the returned access. Constructing an incorrect schema can lead to a panic or unexpected behavior. Use service_schema as a safer alternative, which performs all necessary checks.

Source

pub fn service_schema<'q, S, I>( &self, service_id: I, ) -> Result<S, ArtifactReqError>

Retrieves schema for a service.

§Errors

Returns an error in the following situations (see ArtifactReqError for more details):

  • Service with the given ID does not exist
  • Service has an unexpected artifact name
  • Service has an incompatible artifact version
Source

pub fn for_executing_service(&self) -> Prefixed<T>

Returns a mount point for the data of the executing service instance. Unlike other data, this one may be writeable provided that this BlockchainData wraps a Fork.

Source§

impl BlockchainData<&dyn Snapshot>

Source

pub fn proof_for_service_index(&self, index_name: &str) -> Option<IndexProof>

Returns a proof for a Merkelized index with the specified name in the currently executing service.

§Return value

If the index does not exist or is not Merkelized, returns None. Note that this may occur before the index is accessed the first time, which, depending on the service logic, may happen indefinitely after the service has been initialized. Thus, unwrapping the returned value may unexpectedly lead to a panic unless the index is initialized early (e.g., during service initialization).

Source§

impl<'a, T> BlockchainData<T>
where T: Into<GenericRawAccess<'a>>,

Source

pub fn erase_access(self) -> BlockchainData<GenericRawAccess<'a>>

Erases the enclosed access, converting it to the generic form.

Trait Implementations§

Source§

impl<T: Clone> Clone for BlockchainData<T>

Source§

fn clone(&self) -> BlockchainData<T>

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<T: Debug> Debug for BlockchainData<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for BlockchainData<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for BlockchainData<T>
where T: RefUnwindSafe,

§

impl<T> Send for BlockchainData<T>
where T: Send,

§

impl<T> Sync for BlockchainData<T>
where T: Sync,

§

impl<T> Unpin for BlockchainData<T>
where T: Unpin,

§

impl<T> UnwindSafe for BlockchainData<T>
where T: UnwindSafe,

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, dst: *mut u8)

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