pub struct TcpTransport { /* private fields */ }Expand description
TCP Transport implementation
Supports both client and server modes:
- Client mode: Connect to external service
- Server mode: Accept connections from external services
Implementations§
Source§impl TcpTransport
impl TcpTransport
Sourcepub async fn connect(addr: &str) -> Result<Self>
pub async fn connect(addr: &str) -> Result<Self>
Create a new TCP transport by connecting to an address
Sourcepub async fn connect_with_config(
addr: &str,
config: TransportConfig,
) -> Result<Self>
pub async fn connect_with_config( addr: &str, config: TransportConfig, ) -> Result<Self>
Create a new TCP transport with custom configuration
Sourcepub fn from_stream(stream: TokioTcpStream, config: TransportConfig) -> Self
pub fn from_stream(stream: TokioTcpStream, config: TransportConfig) -> Self
Create a transport from an existing TcpStream (server mode)
Sourcepub fn remote_addr(&self) -> Option<SocketAddr>
pub fn remote_addr(&self) -> Option<SocketAddr>
Get the remote address
Trait Implementations§
Source§impl Transport for TcpTransport
impl Transport for TcpTransport
Source§fn send<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: &'life1 JsonRpcMessage,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: &'life1 JsonRpcMessage,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send a message through the transport
Source§fn receive<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<JsonRpcMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn receive<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<JsonRpcMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Receive a message from the transport
Auto Trait Implementations§
impl !RefUnwindSafe for TcpTransport
impl !UnwindSafe for TcpTransport
impl Freeze for TcpTransport
impl Send for TcpTransport
impl Sync for TcpTransport
impl Unpin for TcpTransport
impl UnsafeUnpin for TcpTransport
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