Skip to main content

StatementApiServer

Trait StatementApiServer 

Source
pub trait StatementApiServer:
    Sized
    + Send
    + Sync
    + 'static {
    // Required methods
    fn submit(&self, encoded: Bytes) -> RpcResult<SubmitResult>;
    fn subscribe_statement(
        &self,
        subscription_sink: PendingSubscriptionSink,
        ext: &Extensions,
        topic_filter: TopicFilter,
    );

    // Provided method
    fn into_rpc(self) -> RpcModule<Self> { ... }
}
Expand description

Server trait implementation for the StatementApi RPC API.

Required Methods§

Source

fn submit(&self, encoded: Bytes) -> RpcResult<SubmitResult>

Submit a SCALE-encoded statement.

See Statement definition for more details.

Returns SubmitResult indicating success or failure reason.

Source

fn subscribe_statement( &self, subscription_sink: PendingSubscriptionSink, ext: &Extensions, topic_filter: TopicFilter, )

Subscribe to new statements that match the provided filters.

§Parameters
  • topic_filter — Which topics to match. Use TopicFilter::Any to match all topics, TopicFilter::MatchAll(vec) to match statements that include all provided topics, or TopicFilter::MatchAny(vec) to match statements that include any of the provided topics.
§Returns

Returns a stream of StatementEvent values. When a subscription is initiated the endpoint will first return all matching statements already in the store in batches as StatementEvent::NewStatements.

NewStatements includes an Optional field remaining which indicates how many more statements are left to be sent in the initial batch of existing statements. The field guarantees to the client that it will receive at least this many more statements in the subscription stream, but it may receive more if new statements are added to the store that match the filter.

If there are no statements in the store matching the filter, an empty batch of statements is sent.

Provided Methods§

Source

fn into_rpc(self) -> RpcModule<Self>

Collects all the methods and subscriptions defined in the trait and adds them into a single RpcModule.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§