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
impl NdjsonConfig
Sourcepub fn with_empty_line_handling(
self,
empty_line_handling: EmptyLineHandling,
) -> NdjsonConfig
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.
Sourcepub fn with_parse_rest(self, parse_rest: bool) -> NdjsonConfig
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
impl Clone for NdjsonConfig
Source§fn clone(&self) -> NdjsonConfig
fn clone(&self) -> NdjsonConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more