Struct Buffer

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

Buffer handler responsible for storing slitted JSONs into memory

Implementations§

Source§

impl Buffer

Source

pub fn new() -> Self

Creates a new handler which stores output within itself

Source

pub fn set_use_path(self, use_path: bool) -> Self

Set whether to show path

§Arguments
  • use_path - should path be store with data
§Example
use streamson_lib::handler;
let file = handler::Buffer::new().set_use_path(true);
Source

pub fn pop(&mut self) -> Option<(Option<String>, Vec<u8>)>

Pops the oldest value in the buffer

§Returns
  • None - queue is empty
  • Some((path, data)) - stored data remove from the queue and returned
§Example
use streamson_lib::handler;
let mut buffer = handler::buffer::Buffer::new().set_use_path(true);
while let Some((path, data)) = buffer.pop() {
    // Do something with the data
    println!("{} (len {})", path.unwrap(), data.len());
}

Source

pub fn set_max_buffer_size(self, max_size: Option<usize>) -> Self

Sets max buffer size

§Arguments
  • use_path - should path be store with data

Trait Implementations§

Source§

impl Debug for Buffer

Source§

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

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

impl Default for Buffer

Source§

fn default() -> Self

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

impl FromStr for Buffer

Source§

type Err = Handler

The associated error which can be returned from parsing.
Source§

fn from_str(input: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Handler for Buffer

Source§

fn start( &mut self, _path: &Path, _matcher_idx: usize, token: Token, ) -> Result<Option<Vec<u8>>, Handler>

Is called when a path is matched Read more
Source§

fn feed( &mut self, data: &[u8], _matcher_idx: usize, ) -> Result<Option<Vec<u8>>, Handler>

Is called when handler receives some data Read more
Source§

fn end( &mut self, _path: &Path, _matcher_idx: usize, token: Token, ) -> Result<Option<Vec<u8>>, Handler>

Is called when the path is no longer matched Read more
Source§

fn as_any(&self) -> &dyn Any

Function to allow downcasting
Source§

fn is_converter(&self) -> bool

Should be handler used to convert data

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.