Struct subxt_lightclient::LightClientRpc
source · pub struct LightClientRpc { /* private fields */ }Expand description
The light-client RPC implementation that is used to connect with the chain.
Implementations§
source§impl LightClientRpc
impl LightClientRpc
sourcepub fn new(
config: AddChainConfig<'_, (), impl IntoIterator<Item = ChainId>>
) -> Result<LightClientRpc, LightClientRpcError>
pub fn new( config: AddChainConfig<'_, (), impl IntoIterator<Item = ChainId>> ) -> Result<LightClientRpc, LightClientRpcError>
Constructs a new LightClientRpc, providing the chain specification.
The chain specification can be downloaded from a trusted network via
the sync_state_genSyncSpec RPC method. This parameter expects the
chain spec in text format (ie not in hex-encoded scale-encoded as RPC methods
will provide).
§Panics
The panic behaviour depends on the feature flag being used:
§Native
Panics when called outside of a tokio runtime context.
§Web
If smoldot panics, then the promise created will be leaked. For more details, see https://docs.rs/wasm-bindgen-futures/latest/wasm_bindgen_futures/fn.future_to_promise.html.
sourcepub fn new_from_client<TPlat>(
client: Client<TPlat>,
chains: impl IntoIterator<Item = AddedChain>
) -> RawLightClientRpcwhere
TPlat: PlatformRef + Clone,
pub fn new_from_client<TPlat>(
client: Client<TPlat>,
chains: impl IntoIterator<Item = AddedChain>
) -> RawLightClientRpcwhere
TPlat: PlatformRef + Clone,
Constructs a new RawLightClientRpc from the raw smoldot client.
Receives a list of RPC objects as a result of calling smoldot_light::Client::add_chain.
This RawLightClientRpc can target different chains using RawLightClientRpc::for_chain method.
§Panics
The panic behaviour depends on the feature flag being used:
§Native
Panics when called outside of a tokio runtime context.
§Web
If smoldot panics, then the promise created will be leaked. For more details, see https://docs.rs/wasm-bindgen-futures/latest/wasm_bindgen_futures/fn.future_to_promise.html.
sourcepub fn method_request(
&self,
method: String,
params: String
) -> Result<Receiver<Result<Box<RawValue>, LightClientRpcError>>, SendError<FromSubxt>>
pub fn method_request( &self, method: String, params: String ) -> Result<Receiver<Result<Box<RawValue>, LightClientRpcError>>, SendError<FromSubxt>>
Submits an RPC method request to the light-client.
This method sends a request to the light-client to execute an RPC method with the provided parameters. The parameters are parsed into a valid JSON object in the background.
sourcepub fn subscription_request(
&self,
method: String,
params: String
) -> Result<(Receiver<Result<Box<RawValue>, LightClientRpcError>>, UnboundedReceiver<Box<RawValue>>), SendError<FromSubxt>>
pub fn subscription_request( &self, method: String, params: String ) -> Result<(Receiver<Result<Box<RawValue>, LightClientRpcError>>, UnboundedReceiver<Box<RawValue>>), SendError<FromSubxt>>
Makes an RPC subscription call to the light-client.
This method sends a request to the light-client to establish an RPC subscription with the provided parameters. The parameters are parsed into a valid JSON object in the background.
Trait Implementations§
source§impl Clone for LightClientRpc
impl Clone for LightClientRpc
source§fn clone(&self) -> LightClientRpc
fn clone(&self) -> LightClientRpc
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for LightClientRpc
impl Send for LightClientRpc
impl Sync for LightClientRpc
impl Unpin for LightClientRpc
impl !UnwindSafe for LightClientRpc
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.