Skip to main content

BufferStore

Struct BufferStore 

Source
pub struct BufferStore { /* private fields */ }
Expand description

Server-wide buffer store.

Buffers are server-global state, not session-keyed. Unnamed buffers use deterministic names (buffer0, buffer1, …) from a monotonically increasing sequence. The allocator skips names already occupied by existing buffers, including explicit named buffers. FIFO eviction at the effective buffer-limit removes only unnamed buffers.

Implementations§

Source§

impl BufferStore

Source

pub fn new() -> Self

Creates an empty buffer store.

Source

pub fn len(&self) -> usize

Returns the number of buffers currently stored.

Source

pub fn is_empty(&self) -> bool

Returns whether the store contains no buffers.

Source

pub fn stack_head(&self) -> Option<&str>

Returns the name of the stack-head buffer (most recently created/replaced).

Source

pub fn top_unnamed(&self) -> Option<&str>

Returns the name of the most recent automatic buffer.

Source

pub fn get(&self, name: &str) -> Option<&[u8]>

Returns the content of the named buffer, or None if it does not exist.

Source

pub fn set( &mut self, name: Option<&str>, content: Vec<u8>, buffer_limit: usize, ) -> Result<SetBufferOutcome, RmuxError>

Sets a named buffer, replacing it if it already exists.

When name is Some, the buffer is created or replaced with that name. When name is None, a new unnamed buffer is created with the next deterministic name.

Zero-length content succeeds without creating or replacing any buffer.

Returns a list of buffer names evicted by FIFO unnamed eviction (may be empty), followed by the optional name of the created/replaced buffer.

Source

pub fn rename( &mut self, old_name: Option<&str>, new_name: &str, ) -> Result<RenameBufferOutcome, RmuxError>

Renames a buffer, replacing any existing destination buffer.

Source

pub fn delete(&mut self, name: Option<&str>) -> Result<String, RmuxError>

Deletes a buffer by name.

When name is None, deletes the most recent automatic buffer. Returns the name of the deleted buffer.

Source

pub fn delete_if_order_matches(&mut self, name: &str, order: u64) -> bool

Deletes a buffer only when the current entry still matches order.

Returns true when the matching entry was removed. Returns false when the buffer is absent or has since been replaced.

Source

pub fn show(&self, name: Option<&str>) -> Result<(&str, &[u8]), RmuxError>

Returns the content of a buffer by name, or the most recent automatic buffer when name is None.

Source

pub fn show_with_order( &self, name: Option<&str>, ) -> Result<(&str, &[u8], u64), RmuxError>

Returns the content and current replacement order for a buffer.

Source

pub fn entries(&self) -> Vec<BufferView<'_>>

Returns immutable buffer entries for server-side formatting and sorting.

Source

pub fn list(&self) -> Vec<String>

Returns a formatted listing of all buffers, ordered by most recent first.

Trait Implementations§

Source§

impl Clone for BufferStore

Source§

fn clone(&self) -> BufferStore

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BufferStore

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for BufferStore

Source§

fn default() -> BufferStore

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.