pub struct ClientBuilder<B, W = JsonCodec> {
inner: ClientConfig,
byte_codec: B,
ws_codec: W,
executor: Option<Executor>,
}Expand description
Builder for constructing an RPC Client.
§Example
use karyon_jsonrpc::client::ClientBuilder;
async {
let client = ClientBuilder::new("tcp://127.0.0.1:60000")
.expect("create builder")
.set_timeout(5000)
.build().await
.expect("build client");
let result: i32 = client
.call("Calc.add", (1, 2))
.await
.expect("call method");
};Fields§
§inner: ClientConfig§byte_codec: B§ws_codec: W§executor: Option<Executor>Implementations§
Source§impl ClientBuilder<JsonCodec, JsonCodec>
impl ClientBuilder<JsonCodec, JsonCodec>
Sourcepub fn new(
endpoint: impl ToEndpoint,
) -> Result<ClientBuilder<JsonCodec, JsonCodec>>
pub fn new( endpoint: impl ToEndpoint, ) -> Result<ClientBuilder<JsonCodec, JsonCodec>>
Create a builder with the default JSON codec.
Source§impl<B: JsonRpcCodec> ClientBuilder<B, JsonCodec>
impl<B: JsonRpcCodec> ClientBuilder<B, JsonCodec>
Sourcepub fn new_with_codec(
endpoint: impl ToEndpoint,
codec: B,
) -> Result<ClientBuilder<B, JsonCodec>>
pub fn new_with_codec( endpoint: impl ToEndpoint, codec: B, ) -> Result<ClientBuilder<B, JsonCodec>>
Create a builder with a custom byte-stream codec. The default
JsonCodec is used for ws:// / wss:// endpoints; override
with with_ws_codec.
Source§impl<B, W> ClientBuilder<B, W>where
B: JsonRpcCodec,
W: WsCodec,
impl<B, W> ClientBuilder<B, W>where
B: JsonRpcCodec,
W: WsCodec,
Sourcepub fn set_timeout(self, timeout: u64) -> Self
pub fn set_timeout(self, timeout: u64) -> Self
Set request timeout in milliseconds.
Sourcepub fn set_max_subscription_buffer_size(self, size: usize) -> Self
pub fn set_max_subscription_buffer_size(self, size: usize) -> Self
Set max subscription buffer size.
Sourcepub fn tcp_config(self, config: TcpConfig) -> Result<Self>
pub fn tcp_config(self, config: TcpConfig) -> Result<Self>
Set TCP config.
Sourcepub fn tls_config(self, config: ClientTlsConfig) -> Result<Self>
pub fn tls_config(self, config: ClientTlsConfig) -> Result<Self>
Set TLS config.
Sourcepub fn quic_config(self, config: ClientQuicConfig) -> Result<Self>
pub fn quic_config(self, config: ClientQuicConfig) -> Result<Self>
Set QUIC config.
Sourcepub fn with_ws_codec<W2: WsCodec>(self, ws_codec: W2) -> ClientBuilder<B, W2>
pub fn with_ws_codec<W2: WsCodec>(self, ws_codec: W2) -> ClientBuilder<B, W2>
Override the WebSocket codec. Only meaningful for ws:// /
wss:// endpoints.
Sourcepub fn with_executor(self, ex: Executor) -> Self
pub fn with_executor(self, ex: Executor) -> Self
Set an executor. Used for the client’s task group.
Auto Trait Implementations§
impl<B, W> Freeze for ClientBuilder<B, W>
impl<B, W = JsonCodec> !RefUnwindSafe for ClientBuilder<B, W>
impl<B, W> Send for ClientBuilder<B, W>
impl<B, W> Sync for ClientBuilder<B, W>
impl<B, W> Unpin for ClientBuilder<B, W>
impl<B, W> UnsafeUnpin for ClientBuilder<B, W>where
B: UnsafeUnpin,
W: UnsafeUnpin,
impl<B, W = JsonCodec> !UnwindSafe for ClientBuilder<B, W>
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
Mutably borrows from an owned value. Read more