Skip to main content

DynBuffer

Trait DynBuffer 

Source
pub trait DynBuffer<T: Clone + Send>: Send + Sync {
    // Required methods
    fn push(&self, value: T);
    fn subscribe_boxed(&self) -> Box<dyn BufferReader<T> + Send>;
    fn as_any(&self) -> &dyn Any;

    // Provided method
    fn peek(&self) -> Option<T> { ... }
}
Expand description

Dynamic buffer trait for trait objects (object-safe)

Type-erased interface for buffers that can be stored as trait objects. Automatically implemented for all Buffer<T> types via blanket impl.

Used when storing heterogeneous buffer types (e.g., in TypedRecord).

Required Methods§

Source

fn push(&self, value: T)

Push a value into the buffer (non-blocking)

Source

fn subscribe_boxed(&self) -> Box<dyn BufferReader<T> + Send>

Create a boxed reader for consuming values

Returns a type-erased reader. Each reader maintains its own position.

Source

fn as_any(&self) -> &dyn Any

Returns self as Any for downcasting to concrete buffer types

Provided Methods§

Source

fn peek(&self) -> Option<T>

Non-destructive read of the buffer’s current value.

Returns Some(T) if the buffer holds a current value that can be read without affecting any consumer’s position. Returns None if the buffer type has no canonical “current value” concept (e.g., SPMC Ring) or if no value has been produced yet.

This is the buffer-native point-in-time read used by AimX record.get . Implementations must not advance any reader position.

The default returns None, which is the correct behaviour for buffers without a canonical latest value.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§