[][src]Struct streamson_lib::strategy::extract::Extract

pub struct Extract { /* fields omitted */ }

Implementations

impl Extract[src]

pub fn new() -> Self[src]

Creates a new Extract

It exracts matched data parts (not nested)

pub fn set_export_path(self, export: bool) -> Self[src]

Sets whether path should be exported with data

if path is not exported extraction can be a bit faster

pub fn add_matcher(&mut self, matcher: Box<dyn MatchMaker>)[src]

Adds new matcher for data extraction

Arguments

  • matcher - matcher which matches the path

Example

use streamson_lib::{strategy, matcher};
use std::sync::{Arc, Mutex};

let mut extract = strategy::Extract::new();
let matcher = matcher::Simple::new(r#"{"list"}[]"#).unwrap();
let mut extract = strategy::Extract::new();
extract.add_matcher(
    Box::new(matcher),
);

pub fn process(
    &mut self,
    input: &[u8]
) -> Result<Vec<(Option<String>, Vec<u8>)>, General>
[src]

Processes input data

Returns

  • Ok(Vec<(Some(r#"{"users"}[0]"#), Vec<u8>)>) vector containing path and data
  • Ok(Vec<(None, Vec<u8>)>) vector data only
  • Err(_) when input is not correct json

Example

use streamson_lib::strategy;

let mut extract = strategy::Extract::new();
extract.process(br#"{}"#);

Errors

  • Error is triggered when incorrect json is detected Note that not all json errors are detected

Trait Implementations

impl Default for Extract[src]

Auto Trait Implementations

impl !RefUnwindSafe for Extract

impl Send for Extract

impl !Sync for Extract

impl Unpin for Extract

impl !UnwindSafe for Extract

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.