Skip to main content

BufSlot

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>

pub fn new(buf: B) -> BufSlot<B>

A fresh slot holding buf, ready to read into / write from.

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>

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>

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>

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

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 take(&mut self) -> Option<B>

Take the buffer to drive an op, leaving the slot InFlight. A readiness leaf restores it with park/fill; a completion leaf leaves it InFlight until the op returns it via fill.

pub fn fill(&mut self, buf: B)

Put the buffer back as idle (a read/write completed).

pub fn park(&mut self, buf: B)

Park the buffer (a readiness backend holds it across Pending).

Trait Implementations§

§

impl<B> Debug for BufSlot<B>
where B: Debug,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a rama_grpc::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

impl<T, U> RamaFrom<T> for U
where U: From<T>,

§

fn rama_from(value: T) -> U

§

impl<T, U, CrateMarker> RamaInto<U, CrateMarker> for T
where U: RamaFrom<T, CrateMarker>,

§

fn rama_into(self) -> U

§

impl<T, U> RamaTryFrom<T> for U
where 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 T
where 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 T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<V, F> ValueFormatter<&V> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

fn format_value(writer: impl ValueWriter, value: &&V)

Write value to writer
§

impl<V, F> ValueFormatter<Arc<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

fn format_value(writer: impl ValueWriter, value: &Arc<V>)

Write value to writer
§

impl<V, F> ValueFormatter<Box<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

fn format_value(writer: impl ValueWriter, value: &Box<V>)

Write value to writer
§

impl<V, F> ValueFormatter<Cow<'_, V>> for F
where V: ToOwned + ?Sized, F: ValueFormatter<V> + ?Sized,

§

fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)

Write value to writer
§

impl<V, F> ValueFormatter<Option<V>> for F
where F: ValueFormatter<V> + ?Sized,

§

fn format_value(writer: impl ValueWriter, value: &Option<V>)

Write value to writer
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more