#[non_exhaustive]pub enum BuiltInConnectionString {
Http(Url),
Ws(Url, Option<Authorization>),
Ipc(PathBuf),
}Expand description
Connection string for built-in transports.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Http(Url)
reqwest or hyper only.HTTP transport.
Ws(Url, Option<Authorization>)
ws only.WebSocket transport.
Ipc(PathBuf)
ipc only.IPC transport.
Implementations§
Source§impl BuiltInConnectionString
impl BuiltInConnectionString
Sourcepub async fn connect(s: &str) -> Result<BoxTransport, TransportError>
pub async fn connect(s: &str) -> Result<BoxTransport, TransportError>
Parse a connection string and connect to it in one go.
This is a convenience method that combines from_str and connect_boxed.
§Example
use alloy_rpc_client::BuiltInConnectionString;
let transport = BuiltInConnectionString::connect("http://localhost:8545").await?;Sourcepub async fn connect_with(
s: &str,
config: ConnectionConfig,
) -> Result<BoxTransport, TransportError>
pub async fn connect_with( s: &str, config: ConnectionConfig, ) -> Result<BoxTransport, TransportError>
Parse a connection string and connect with custom configuration.
This method allows for fine-grained control over connection settings such as authentication, retry behavior, and transport-specific options.
§Examples
Basic usage with authentication:
use alloy_rpc_client::{BuiltInConnectionString, ConnectionConfig};
use alloy_transport::Authorization;
use std::time::Duration;
// Configure connection with custom settings
let config = ConnectionConfig::new()
.with_auth(Authorization::bearer("my-token"))
.with_max_retries(3)
.with_retry_interval(Duration::from_secs(2));
// Connect to WebSocket endpoint with configuration
let transport = BuiltInConnectionString::connect_with("ws://localhost:8545", config).await?;Sourcepub async fn connect_boxed(&self) -> Result<BoxTransport, TransportError>
pub async fn connect_boxed(&self) -> Result<BoxTransport, TransportError>
Connect with the given connection string.
§Notes
- If
hyperfeature is enabled - WS will extract auth, however, auth is disabled for wasm.
Sourcepub async fn connect_boxed_with(
&self,
config: ConnectionConfig,
) -> Result<BoxTransport, TransportError>
pub async fn connect_boxed_with( &self, config: ConnectionConfig, ) -> Result<BoxTransport, TransportError>
Connect with the given connection string and custom configuration.
This method provides fine-grained control over connection settings. Configuration options are applied where supported by the transport.
§Notes
- If
hyperfeature is enabled - WS will extract auth, however, auth is disabled for wasm.
- Some configuration options may not apply to all transport types.
Sourcepub fn try_as_http(s: &str) -> Result<Self, TransportError>
Available on crate features reqwest or hyper only.
pub fn try_as_http(s: &str) -> Result<Self, TransportError>
reqwest or hyper only.Tries to parse the given string as an HTTP URL.
Sourcepub fn try_as_ws(s: &str) -> Result<Self, TransportError>
Available on crate feature ws only.
pub fn try_as_ws(s: &str) -> Result<Self, TransportError>
ws only.Tries to parse the given string as a WebSocket URL.
Sourcepub fn try_as_ipc(s: &str) -> Result<Self, TransportError>
Available on crate feature ipc only.
pub fn try_as_ipc(s: &str) -> Result<Self, TransportError>
ipc only.Tries to parse the given string as an IPC path, returning an error if the path does not exist.
Trait Implementations§
Source§impl Clone for BuiltInConnectionString
impl Clone for BuiltInConnectionString
Source§fn clone(&self) -> BuiltInConnectionString
fn clone(&self) -> BuiltInConnectionString
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BuiltInConnectionString
impl Debug for BuiltInConnectionString
Source§impl FromStr for BuiltInConnectionString
impl FromStr for BuiltInConnectionString
Source§impl PartialEq for BuiltInConnectionString
impl PartialEq for BuiltInConnectionString
Source§impl TransportConnect for BuiltInConnectionString
impl TransportConnect for BuiltInConnectionString
Source§async fn get_transport(&self) -> Result<BoxTransport, TransportError>
async fn get_transport(&self) -> Result<BoxTransport, TransportError>
Transport instance.impl Eq for BuiltInConnectionString
impl StructuralPartialEq for BuiltInConnectionString
Auto Trait Implementations§
impl Freeze for BuiltInConnectionString
impl RefUnwindSafe for BuiltInConnectionString
impl Send for BuiltInConnectionString
impl Sync for BuiltInConnectionString
impl Unpin for BuiltInConnectionString
impl UnwindSafe for BuiltInConnectionString
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 120 bytes
Size for each variant:
Http: 96 bytesWs: 120 bytesIpc: 32 bytes