pub struct NetTransport<I, A, S, R>where
I: Id,
A: AddressResolver<ResolvedAddress = SocketAddr, Runtime = R>,
S: StreamLayer<Runtime = R>,
R: Runtime,{ /* private fields */ }
Expand description
The net transport based on TCP/TLS and UDP
Trait Implementations§
Source§impl<I, A, S, R> Drop for NetTransport<I, A, S, R>where
I: Id,
A: AddressResolver<ResolvedAddress = SocketAddr, Runtime = R>,
S: StreamLayer<Runtime = R>,
R: Runtime,
impl<I, A, S, R> Drop for NetTransport<I, A, S, R>where
I: Id,
A: AddressResolver<ResolvedAddress = SocketAddr, Runtime = R>,
S: StreamLayer<Runtime = R>,
R: Runtime,
Source§impl<I, A, S, R> Transport for NetTransport<I, A, S, R>where
I: Id + Data + Send + Sync + 'static,
A: AddressResolver<ResolvedAddress = SocketAddr, Runtime = R>,
A::Address: Data + Send + Sync + 'static,
S: StreamLayer<Runtime = R>,
R: Runtime,
impl<I, A, S, R> Transport for NetTransport<I, A, S, R>where
I: Id + Data + Send + Sync + 'static,
A: AddressResolver<ResolvedAddress = SocketAddr, Runtime = R>,
A::Address: Data + Send + Sync + 'static,
S: StreamLayer<Runtime = R>,
R: Runtime,
Source§type Error = NetTransportError<<NetTransport<I, A, S, R> as Transport>::Resolver>
type Error = NetTransportError<<NetTransport<I, A, S, R> as Transport>::Resolver>
The error type for the transport
Source§type Address = <A as AddressResolver>::Address
type Address = <A as AddressResolver>::Address
The address type of the node
Source§type ResolvedAddress = SocketAddr
type ResolvedAddress = SocketAddr
The resolved address type of the node
Source§type Connection = <S as StreamLayer>::Stream
type Connection = <S as StreamLayer>::Stream
The promised connection used to send and receive messages
Source§type Runtime = <<NetTransport<I, A, S, R> as Transport>::Resolver as AddressResolver>::Runtime
type Runtime = <<NetTransport<I, A, S, R> as Transport>::Resolver as AddressResolver>::Runtime
The async runtime
Source§type Options = NetTransportOptions<<NetTransport<I, A, S, R> as Transport>::Id, <NetTransport<I, A, S, R> as Transport>::Resolver, S>
type Options = NetTransportOptions<<NetTransport<I, A, S, R> as Transport>::Id, <NetTransport<I, A, S, R> as Transport>::Resolver, S>
The options used to construct the transport
Source§async fn new(transport_opts: Self::Options) -> Result<Self, Self::Error>
async fn new(transport_opts: Self::Options) -> Result<Self, Self::Error>
Creates a new transport with the given options
Source§async fn resolve(
&self,
addr: &<Self::Resolver as AddressResolver>::Address,
) -> Result<<Self::Resolver as AddressResolver>::ResolvedAddress, Self::Error>
async fn resolve( &self, addr: &<Self::Resolver as AddressResolver>::Address, ) -> Result<<Self::Resolver as AddressResolver>::ResolvedAddress, Self::Error>
Resolves the given address to a resolved address
Source§fn local_address(&self) -> &<Self::Resolver as AddressResolver>::Address
fn local_address(&self) -> &<Self::Resolver as AddressResolver>::Address
Returns the local address of the node
Source§fn advertise_address(
&self,
) -> &<Self::Resolver as AddressResolver>::ResolvedAddress
fn advertise_address( &self, ) -> &<Self::Resolver as AddressResolver>::ResolvedAddress
Returns the advertise address of the node
Source§fn max_packet_size(&self) -> usize
fn max_packet_size(&self) -> usize
Returns the maximum size of a packet that can be sent
Source§fn header_overhead(&self) -> usize
fn header_overhead(&self) -> usize
Returns the header overhead in bytes this transport.
Source§fn blocked_address(
&self,
addr: &<Self::Resolver as AddressResolver>::ResolvedAddress,
) -> Result<(), Self::Error>
fn blocked_address( &self, addr: &<Self::Resolver as AddressResolver>::ResolvedAddress, ) -> Result<(), Self::Error>
Returns an error if the given address is blocked
Source§async fn send_to(
&self,
addr: &<Self::Resolver as AddressResolver>::ResolvedAddress,
packets: Payload,
) -> Result<(usize, <Self::Runtime as RuntimeLite>::Instant), Self::Error>
async fn send_to( &self, addr: &<Self::Resolver as AddressResolver>::ResolvedAddress, packets: Payload, ) -> Result<(usize, <Self::Runtime as RuntimeLite>::Instant), Self::Error>
A packet-oriented interface that fires off the given
payload to the given address in a connectionless fashion. Read more
Source§async fn open(
&self,
addr: &<Self::Resolver as AddressResolver>::ResolvedAddress,
deadline: <Self::Runtime as RuntimeLite>::Instant,
) -> Result<Self::Connection, Self::Error>
async fn open( &self, addr: &<Self::Resolver as AddressResolver>::ResolvedAddress, deadline: <Self::Runtime as RuntimeLite>::Instant, ) -> Result<Self::Connection, Self::Error>
Used to create a bidirection connection that allows us to perform
two-way communication with a peer. This is generally more expensive
than packet connections so is used for more infrequent operations
such as anti-entropy or fallback probes if the packet-oriented probe
failed.
Source§fn packet(
&self,
) -> PacketSubscriber<<Self::Resolver as AddressResolver>::ResolvedAddress, <Self::Runtime as RuntimeLite>::Instant>
fn packet( &self, ) -> PacketSubscriber<<Self::Resolver as AddressResolver>::ResolvedAddress, <Self::Runtime as RuntimeLite>::Instant>
Returns a packet subscriber that can be used to receive incoming packets
Source§fn stream(
&self,
) -> StreamSubscriber<<Self::Resolver as AddressResolver>::ResolvedAddress, Self::Connection>
fn stream( &self, ) -> StreamSubscriber<<Self::Resolver as AddressResolver>::ResolvedAddress, Self::Connection>
Returns a receiver that can be read to handle incoming stream
connections from other peers. How this is set up for listening is
left as an exercise for the concrete transport implementations.
Source§fn packet_reliable(&self) -> bool
fn packet_reliable(&self) -> bool
Returns
true
if the transport provides provides reliable packets delivery. Read moreSource§fn packet_secure(&self) -> bool
fn packet_secure(&self) -> bool
Returns
true
if the transport provides packets security. Read moreSource§fn stream_secure(&self) -> bool
fn stream_secure(&self) -> bool
Returns
true
if the transport provides stream security. Read moreSource§fn read(
&self,
from: &Self::ResolvedAddress,
conn: &mut <Self::Connection as Connection>::Reader,
) -> impl Future<Output = Result<usize, Self::Error>> + Send
fn read( &self, from: &Self::ResolvedAddress, conn: &mut <Self::Connection as Connection>::Reader, ) -> impl Future<Output = Result<usize, Self::Error>> + Send
This is a hook that allows the transport to perform any extra work
when the memberlist accepts a new connection from a remote node. Read more
Auto Trait Implementations§
impl<I, A, S, R> !Freeze for NetTransport<I, A, S, R>
impl<I, A, S, R> !RefUnwindSafe for NetTransport<I, A, S, R>
impl<I, A, S, R> Send for NetTransport<I, A, S, R>
impl<I, A, S, R> Sync for NetTransport<I, A, S, R>
impl<I, A, S, R> !Unpin for NetTransport<I, A, S, R>
impl<I, A, S, R> !UnwindSafe for NetTransport<I, A, S, R>
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more