Skip to main content

Buffer

Struct Buffer 

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

Manager for the retrospective buffer.

Implementations§

Source§

impl Buffer

Source

pub fn new(config: Config) -> Self

Create a new buffer manager.

Source

pub fn is_enabled(&self) -> bool

Check if buffering is enabled.

Source

pub fn init(&self) -> Result<()>

Initialize the buffer directory with secure permissions.

Source

pub fn should_exclude(&self, cmd: &str) -> bool

Check if a command should be excluded from buffering.

Combines hooks.ignore_patterns and buffer.exclude_patterns.

Source

pub fn start_entry( &self, cmd: &str, cwd: &str, session_id: &str, ) -> Result<Uuid>

Start a new buffer entry. Returns the entry ID for writing output.

Source

pub fn complete_entry( &self, id: &Uuid, exit_code: i32, duration_ms: i64, ) -> Result<()>

Complete a buffer entry with exit code and duration.

Source

pub fn write_complete_entry( &self, cmd: &str, cwd: &str, session_id: &str, exit_code: i32, duration_ms: Option<i64>, output: Option<&[u8]>, ) -> Result<Uuid>

Write a complete buffer entry at once (for shq save --to-buffer).

This is used when all data is available at once (command already completed).

Source

pub fn list_entries(&self) -> Result<Vec<BufferEntry>>

List all buffer entries, sorted by start time (most recent first).

Source

pub fn get_by_position(&self, position: usize) -> Result<Option<BufferEntry>>

Get a buffer entry by position (1 = most recent).

Source

pub fn get_by_id(&self, id: &Uuid) -> Result<Option<BufferEntry>>

Get a buffer entry by ID.

Source

pub fn read_output(&self, entry: &BufferEntry) -> Result<Vec<u8>>

Read output from a buffer entry.

Source

pub fn delete_entry(&self, id: &Uuid) -> Result<()>

Delete a buffer entry.

Source

pub fn clear(&self) -> Result<usize>

Clear all buffer entries.

Source

pub fn rotate(&self) -> Result<usize>

Rotate buffer entries based on configured limits.

Auto Trait Implementations§

§

impl Freeze for Buffer

§

impl RefUnwindSafe for Buffer

§

impl Send for Buffer

§

impl Sync for Buffer

§

impl Unpin for Buffer

§

impl UnwindSafe for Buffer

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

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

Source§

fn vzip(self) -> V

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,