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>
impl<T: RawAccess + AsReadonly> BlockchainData<T>
Sourcepub fn new(access: T, instance_name: impl Into<String>) -> Self
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.
Sourcepub fn instance_name(&self) -> &str
pub fn instance_name(&self) -> &str
Returns the instance name of the executing service.
Sourcepub fn for_core(&self) -> CoreSchema<T::Readonly>
pub fn for_core(&self) -> CoreSchema<T::Readonly>
Returns core schema.
Sourcepub fn for_dispatcher(&self) -> DispatcherSchema<T::Readonly>
pub fn for_dispatcher(&self) -> DispatcherSchema<T::Readonly>
Returns dispatcher schema.
Sourcepub fn for_service<'q>(
&self,
id: impl Into<InstanceQuery<'q>>,
) -> Option<Prefixed<T::Readonly>>
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.
Sourcepub fn service_schema<'q, S, I>(
&self,
service_id: I,
) -> Result<S, ArtifactReqError>
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
Sourcepub fn for_executing_service(&self) -> Prefixed<T>
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>
impl BlockchainData<&dyn Snapshot>
Sourcepub fn proof_for_service_index(&self, index_name: &str) -> Option<IndexProof>
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>>,
impl<'a, T> BlockchainData<T>where
T: Into<GenericRawAccess<'a>>,
Sourcepub fn erase_access(self) -> BlockchainData<GenericRawAccess<'a>>
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>
impl<T: Clone> Clone for BlockchainData<T>
Source§fn clone(&self) -> BlockchainData<T>
fn clone(&self) -> BlockchainData<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more