BufferExt

Trait BufferExt 

Source
pub trait BufferExt {
    // Required methods
    fn read_all(&self) -> Vec<u8> ;
    fn read_to_string(&self) -> VtxResult<String>;
    fn read_json<T: DeserializeOwned>(&self) -> VtxResult<T>;
    fn write_all(&self, data: impl AsRef<[u8]>) -> u64;
}
Expand description

Convenience extension methods for Buffer resources.

Required Methods§

Source

fn read_all(&self) -> Vec<u8>

Reads the entire Buffer.

  • For file/memory: Uses size() for chunked reading.
  • For pipe: Reads continuously until EOF (returns empty array) or max_total_bytes is reached.

IO Boundary: This method reads a maximum of 64MB (MAX_TOTAL).

Source

fn read_to_string(&self) -> VtxResult<String>

Reads the entire Buffer as UTF-8.

Source

fn read_json<T: DeserializeOwned>(&self) -> VtxResult<T>

Deserializes JSON in the Buffer into the target type.

Source

fn write_all(&self, data: impl AsRef<[u8]>) -> u64

Appends data to the Buffer (File: append; Pipe: write to stdin; Memory: append).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§