Struct NdjsonConfig

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

Configuration for the NDJSON-parser which controls the behavior in various situations.

By default, the parser will attempt to parse every line, i.e. every segment between \n characters, even if it is empty. This will result in errors for empty lines.

You can construct a config by first calling NdjsonConfig::default and then using the builder-style associated functions to configure it. See the example below.

use ndjson_stream::config::{EmptyLineHandling, NdjsonConfig};

let config = NdjsonConfig::default()
    .with_empty_line_handling(EmptyLineHandling::IgnoreBlank)
    .with_parse_rest(true);

Implementations§

Source§

impl NdjsonConfig

Source

pub fn with_empty_line_handling( self, empty_line_handling: EmptyLineHandling, ) -> NdjsonConfig

Creates a new config from this config which has a different handling for lines that contain no JSON values. See EmptyLineHandling for more details.

§Returns

A new config with all the same values as this one, except the empty-line-handling.

Source

pub fn with_parse_rest(self, parse_rest: bool) -> NdjsonConfig

Creates a new config from this config which has the given configuration on whether to parse or ignore the rest, i.e. the part after the last newline character. If parse_rest is set to false, the rest will always be ignored, while true causes it to only be ignored if it is empty or considered empty by the handling configured in NdjsonConfig::with_empty_line_handling, which by default is only truly empty. Otherwise, the rest is parsed like an ordinary JSON record. By default, this is set to false.

§Returns

A new config with all the same values as this one, except the parse-rest-flag.

Trait Implementations§

Source§

impl Clone for NdjsonConfig

Source§

fn clone(&self) -> NdjsonConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for NdjsonConfig

Source§

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

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

impl Default for NdjsonConfig

Source§

fn default() -> NdjsonConfig

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

impl Hash for NdjsonConfig

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for NdjsonConfig

Source§

fn eq(&self, other: &NdjsonConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for NdjsonConfig

Source§

impl Eq for NdjsonConfig

Source§

impl StructuralPartialEq for NdjsonConfig

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.