Struct MemoryDatagramSocket
pub struct MemoryDatagramSocket { /* private fields */ }std and crate feature udp and (crate features test-utils) only.Expand description
One endpoint of an in-memory datagram pair used by protocol tests.
Sending from either endpoint queues a datagram for the other. The fixed queue capacity models backpressure without using an operating-system socket.
Implementations§
§impl MemoryDatagramSocket
impl MemoryDatagramSocket
pub fn pair(
first: impl Into<SocketAddress>,
second: impl Into<SocketAddress>,
capacity: NonZero<usize>,
) -> (MemoryDatagramSocket, MemoryDatagramSocket)
pub fn pair( first: impl Into<SocketAddress>, second: impl Into<SocketAddress>, capacity: NonZero<usize>, ) -> (MemoryDatagramSocket, MemoryDatagramSocket)
Construct two connected endpoints with capacity datagrams per side.
pub fn fault_control(&self) -> MemoryDatagramControl
pub fn fault_control(&self) -> MemoryDatagramControl
Control loss and reordering on datagrams sent by this endpoint.
The handle does not keep either endpoint logically open.
pub fn inject_received(
&self,
payload: Vec<u8>,
metadata: DatagramMetadata,
) -> Result<(), DatagramError>
pub fn inject_received( &self, payload: Vec<u8>, metadata: DatagramMetadata, ) -> Result<(), DatagramError>
Insert a datagram directly into this endpoint’s receive queue.
This is useful for deterministic tests of metadata that cannot be produced by the ordinary paired send path, such as original destination.
pub fn set_max_send_segments(&self, value: NonZero<usize>)
pub fn set_max_send_segments(&self, value: NonZero<usize>)
Change the segmented-send limit exposed by both endpoints.
This deterministic hook lets protocol tests model a backend that lowers its offload limit after a runtime rejection. Already-created sender handles observe the new value through their next capability query.
pub fn set_max_payload(&self, value: usize)
pub fn set_max_payload(&self, value: usize)
Lower the payload limit both endpoints expose and enforce, as a UDP tunnel whose path
shrank does; larger sends fail with DatagramError::PayloadTooLarge. Existing
sender handles observe it on their next send.
pub fn set_send_source_port(&self, enabled: bool)
pub fn set_send_source_port(&self, enabled: bool)
Let both endpoints select a reply’s source port too (off by default), as a transparent proxy flow can.
Trait Implementations§
§impl DatagramSocket for MemoryDatagramSocket
impl DatagramSocket for MemoryDatagramSocket
§type Sender = MemoryDatagramSender
type Sender = MemoryDatagramSender
§fn create_sender(&self) -> <MemoryDatagramSocket as DatagramSocket>::Sender
fn create_sender(&self) -> <MemoryDatagramSocket as DatagramSocket>::Sender
§fn poll_recv(
&mut self,
cx: &mut Context<'_>,
buffers: &mut [IoSliceMut<'_>],
metadata: &mut [DatagramMetadata],
) -> Poll<Result<usize, DatagramError>>
fn poll_recv( &mut self, cx: &mut Context<'_>, buffers: &mut [IoSliceMut<'_>], metadata: &mut [DatagramMetadata], ) -> Poll<Result<usize, DatagramError>>
§fn capabilities(&self) -> DatagramCapabilities
fn capabilities(&self) -> DatagramCapabilities
§impl Debug for MemoryDatagramSocket
impl Debug for MemoryDatagramSocket
§impl Drop for MemoryDatagramSocket
impl Drop for MemoryDatagramSocket
§impl ExtensionsRef for MemoryDatagramSocket
impl ExtensionsRef for MemoryDatagramSocket
§fn extensions(&self) -> &Extensions
fn extensions(&self) -> &Extensions
Extensions store§impl Socket for MemoryDatagramSocket
impl Socket for MemoryDatagramSocket
§fn local_addr(&self) -> Result<SocketAddress, Error>
fn local_addr(&self) -> Result<SocketAddress, Error>
§fn peer_addr(&self) -> Result<SocketAddress, Error>
fn peer_addr(&self) -> Result<SocketAddress, Error>
Auto Trait Implementations§
impl !RefUnwindSafe for MemoryDatagramSocket
impl !UnwindSafe for MemoryDatagramSocket
impl Freeze for MemoryDatagramSocket
impl Send for MemoryDatagramSocket
impl Sync for MemoryDatagramSocket
impl Unpin for MemoryDatagramSocket
impl UnsafeUnpin for MemoryDatagramSocket
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<S> DatagramBridgeInput for S
impl<S> DatagramBridgeInput for S
§fn ingress(&self) -> &<S as DatagramBridgeInput>::Ingress
fn ingress(&self) -> &<S as DatagramBridgeInput>::Ingress
§fn bridge<Egress>(
self,
egress: Egress,
) -> <S as DatagramBridgeInput>::Bridged<Egress>where
Egress: Send + 'static,
fn bridge<Egress>(
self,
egress: Egress,
) -> <S as DatagramBridgeInput>::Bridged<Egress>where
Egress: Send + 'static,
egress next to its ingress.§impl<S> DatagramPeekInput for Swhere
S: DatagramSocket,
impl<S> DatagramPeekInput for Swhere
S: DatagramSocket,
§type Mapped<Peeked: DatagramSocket> = Peeked
type Mapped<Peeked: DatagramSocket> = Peeked
PrefixedDatagramSocket.§fn peek_socket_mut(&mut self) -> &mut <S as DatagramPeekInput>::Socket
fn peek_socket_mut(&mut self) -> &mut <S as DatagramPeekInput>::Socket
§fn map_peek_socket<Peeked, F>(
self,
map: F,
) -> <S as DatagramPeekInput>::Mapped<Peeked>
fn map_peek_socket<Peeked, F>( self, map: F, ) -> <S as DatagramPeekInput>::Mapped<Peeked>
map’s result for its peeked socket.§impl<T> DatagramSocketExt for Twhere
T: DatagramSocket + ?Sized,
impl<T> DatagramSocketExt for Twhere
T: DatagramSocket + ?Sized,
§fn recv<'a>(
&'a mut self,
buffer: &'a mut [u8],
) -> impl Future<Output = Result<DatagramMetadata, DatagramError>> + Send + 'awhere
Self: Sized,
fn recv<'a>(
&'a mut self,
buffer: &'a mut [u8],
) -> impl Future<Output = Result<DatagramMetadata, DatagramError>> + Send + 'awhere
Self: Sized,
buffer.§fn recv_batch<'a, 'buffer>(
&'a mut self,
buffers: &'a mut [IoSliceMut<'buffer>],
metadata: &'a mut [DatagramMetadata],
) -> impl Future<Output = Result<usize, DatagramError>> + Send + 'awhere
'buffer: 'a,
Self: Sized,
fn recv_batch<'a, 'buffer>(
&'a mut self,
buffers: &'a mut [IoSliceMut<'buffer>],
metadata: &'a mut [DatagramMetadata],
) -> impl Future<Output = Result<usize, DatagramError>> + Send + 'awhere
'buffer: 'a,
Self: Sized,
§impl<T> ForwardedClientExt for Twhere
T: ExtensionsRef + ?Sized,
impl<T> ForwardedClientExt for Twhere
T: ExtensionsRef + ?Sized,
§fn forwarded_client(&self) -> Option<&ForwardedElement>
fn forwarded_client(&self) -> Option<&ForwardedElement>
§fn forwarded_client_ip(&self) -> Option<IpAddr>
fn forwarded_client_ip(&self) -> Option<IpAddr>
for node.§fn forwarded_client_socket_addr(&self) -> Option<SocketAddress>
fn forwarded_client_socket_addr(&self) -> Option<SocketAddress>
for node.§fn forwarded_client_host(&self) -> Option<&ForwardedAuthority>
fn forwarded_client_host(&self) -> Option<&ForwardedAuthority>
§fn forwarded_client_proto(&self) -> Option<ForwardedProtocol>
fn forwarded_client_proto(&self) -> Option<ForwardedProtocol>
§fn forwarded_client_version(&self) -> Option<ForwardedVersion>
fn forwarded_client_version(&self) -> Option<ForwardedVersion>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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> ⓘ
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> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more