Enum BufSlot
pub enum BufSlot<B> {
Ready(B),
InFlight,
Parked(B),
}Expand description
An owned buffer slot
The buffer slot threaded through poll_read_owned
/ poll_write_owned. It names who owns
the buffer during an in-flight op, so the in-flight state is never an
ambiguous None, and dropping it is always safe:
Ready: the buffer is here, idle; read into / write from it.InFlight: a completion backend moved the buffer into its op-slab, the slot holds nothing. Dropping is safe, the leaf reaps it.Parked: a readiness backend (tokio) keeps the buffer here between polls (it has no kernel op to hold it). Nothing is DMA-ing into it, so dropping is safe too.
§Usage
The consumer holds it in a persistent field, hands a buffer in once, and it
is reused: tokio recycles via Ready/Parked, a completion backend registers
it (InFlight) and hands it back. Construct with new, read
the result via ready_mut. The buffer-carrying variants
are constructed only by leaves (via park /
fill), so a consumer can’t fish a buffer out mid-op.
Variants§
Ready(B)
The buffer is here and idle, no op in flight, so it can be read or handed to a new op. This is both a fresh buffer and one holding a completed result, the slot tracks where the buffer is, not what’s in it.
InFlight
In flight on a completion backend, the buffer is in the leaf’s op-slab.
Parked(B)
Held by a readiness backend between polls (buffer present, mid-operation).
Implementations§
§impl<B> BufSlot<B>
impl<B> BufSlot<B>
pub fn ready(&self) -> Option<&B>
pub fn ready(&self) -> Option<&B>
The completed buffer by shared ref, only when idle (Ready,
the op finished). None while a read/write is still in flight (InFlight
or readiness-held Parked): a mid-operation buffer is never handed out for
reading.
pub fn ready_mut(&mut self) -> Option<&mut B>
pub fn ready_mut(&mut self) -> Option<&mut B>
The buffer when idle (Ready), where the consumer reads
the result after a completed read. None while in flight.
pub fn take_ready(self) -> Option<B>
pub fn take_ready(self) -> Option<B>
Take the completed buffer, consuming the slot, only when idle
(Ready, the op finished). None if a read/write is still in
flight (InFlight or readiness-held Parked), so a caller can’t mistake a
mid-operation buffer for a result. This is the normal “the read/write
returned Ready, give me my buffer back” path. To recover the buffer
regardless of op state, use reclaim.
pub fn reclaim(self) -> Option<B>
pub fn reclaim(self) -> Option<B>
Recover the buffer whenever it’s present (idle Ready or readiness-held
Parked), consuming the slot. None only while a completion op owns it
(InFlight). For adapters that drive the poll themselves and reclaim the
buffer across a Pending/Err (e.g. reusing its staging capacity,
or a racing timeout short-circuiting a read): the contents may be
mid-operation, so this is recovery, not result extraction, use
take_ready for the latter.
pub fn is_ready(&self) -> bool
pub fn is_ready(&self) -> bool
Whether the buffer is idle and here (Ready), i.e. it can
be read into / written from right now. false means a read/write is still
in flight (InFlight on a completion backend, Parked on a readiness one)
and must be resumed via the leaf before the buffer is touched again.
pub fn fill(&mut self, buf: B)
pub fn fill(&mut self, buf: B)
Put the buffer back as idle (a read/write completed).
pub fn park(&mut self, buf: B)
pub fn park(&mut self, buf: B)
Park the buffer (a readiness backend holds it across Pending).
Trait Implementations§
Auto Trait Implementations§
impl<B> Freeze for BufSlot<B>where
B: Freeze,
impl<B> RefUnwindSafe for BufSlot<B>where
B: RefUnwindSafe,
impl<B> Send for BufSlot<B>where
B: Send,
impl<B> Sync for BufSlot<B>where
B: Sync,
impl<B> Unpin for BufSlot<B>where
B: Unpin,
impl<B> UnsafeUnpin for BufSlot<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for BufSlot<B>where
B: UnwindSafe,
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<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§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writer§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writer§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writer§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writer§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer