Struct ParseConfig
pub struct ParseConfig { /* private fields */ }Expand description
Configuration for the NDJSON-parser which controls the behavior in various situations.
By default, the parser will skip empty lines (EmptyLineHandling::IgnoreEmpty) and accept
lines of unbounded size. The unbounded line size is safe only for trusted input — when
parsing data from an untrusted peer (e.g. a remote proxy backend), set
ParseConfig::with_max_line_bytes to bound memory usage. Oversized lines are reported as a
parse error and the engine resyncs to the next newline so subsequent lines can still be
decoded.
You can construct a config by first calling ParseConfig::default and then using the
builder-style associated functions to configure it. See the example below.
Implementations§
§impl ParseConfig
impl ParseConfig
pub fn with_empty_line_handling(
self,
empty_line_handling: EmptyLineHandling,
) -> ParseConfig
pub fn with_empty_line_handling( self, empty_line_handling: EmptyLineHandling, ) -> ParseConfig
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.
pub fn set_empty_line_handling(
&mut self,
empty_line_handling: EmptyLineHandling,
) -> &mut ParseConfig
pub fn set_empty_line_handling( &mut self, empty_line_handling: EmptyLineHandling, ) -> &mut ParseConfig
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.
pub fn with_parse_rest(self, parse_rest: bool) -> ParseConfig
pub fn with_parse_rest(self, parse_rest: bool) -> ParseConfig
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
ParseConfig::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 true.
§Returns
A new config with all the same values as this one, except the parse-rest-flag.
pub fn set_parse_rest(&mut self, parse_rest: bool) -> &mut ParseConfig
pub fn set_parse_rest(&mut self, parse_rest: bool) -> &mut ParseConfig
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
ParseConfig::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 true.
§Returns
A new config with all the same values as this one, except the parse-rest-flag.
pub fn maybe_with_max_line_bytes(
self,
max_line_bytes: Option<NonZero<usize>>,
) -> ParseConfig
pub fn maybe_with_max_line_bytes( self, max_line_bytes: Option<NonZero<usize>>, ) -> ParseConfig
Caps the size of a single NDJSON line. When the accumulated bytes for a single line
(i.e. between two \n characters) exceed this limit, the engine emits a parse error
and resynchronises to the next newline; subsequent lines can still be decoded.
None (the default) means no limit — appropriate only for trusted input sources.
Set this for any NDJSON stream sourced from an untrusted peer to avoid unbounded
memory growth from a peer that never sends a \n.
§Returns
A new config with all the same values as this one, except the max-line-bytes.
pub fn maybe_set_max_line_bytes(
&mut self,
max_line_bytes: Option<NonZero<usize>>,
) -> &mut ParseConfig
pub fn maybe_set_max_line_bytes( &mut self, max_line_bytes: Option<NonZero<usize>>, ) -> &mut ParseConfig
Caps the size of a single NDJSON line. When the accumulated bytes for a single line
(i.e. between two \n characters) exceed this limit, the engine emits a parse error
and resynchronises to the next newline; subsequent lines can still be decoded.
None (the default) means no limit — appropriate only for trusted input sources.
Set this for any NDJSON stream sourced from an untrusted peer to avoid unbounded
memory growth from a peer that never sends a \n.
§Returns
A new config with all the same values as this one, except the max-line-bytes.
pub fn with_max_line_bytes(self, max_line_bytes: NonZero<usize>) -> ParseConfig
pub fn with_max_line_bytes(self, max_line_bytes: NonZero<usize>) -> ParseConfig
Caps the size of a single NDJSON line. When the accumulated bytes for a single line
(i.e. between two \n characters) exceed this limit, the engine emits a parse error
and resynchronises to the next newline; subsequent lines can still be decoded.
None (the default) means no limit — appropriate only for trusted input sources.
Set this for any NDJSON stream sourced from an untrusted peer to avoid unbounded
memory growth from a peer that never sends a \n.
§Returns
A new config with all the same values as this one, except the max-line-bytes.
pub fn set_max_line_bytes(
&mut self,
max_line_bytes: NonZero<usize>,
) -> &mut ParseConfig
pub fn set_max_line_bytes( &mut self, max_line_bytes: NonZero<usize>, ) -> &mut ParseConfig
Caps the size of a single NDJSON line. When the accumulated bytes for a single line
(i.e. between two \n characters) exceed this limit, the engine emits a parse error
and resynchronises to the next newline; subsequent lines can still be decoded.
None (the default) means no limit — appropriate only for trusted input sources.
Set this for any NDJSON stream sourced from an untrusted peer to avoid unbounded
memory growth from a peer that never sends a \n.
§Returns
A new config with all the same values as this one, except the max-line-bytes.
pub fn without_max_line_bytes(self) -> ParseConfig
pub fn without_max_line_bytes(self) -> ParseConfig
Caps the size of a single NDJSON line. When the accumulated bytes for a single line
(i.e. between two \n characters) exceed this limit, the engine emits a parse error
and resynchronises to the next newline; subsequent lines can still be decoded.
None (the default) means no limit — appropriate only for trusted input sources.
Set this for any NDJSON stream sourced from an untrusted peer to avoid unbounded
memory growth from a peer that never sends a \n.
§Returns
A new config with all the same values as this one, except the max-line-bytes.
pub fn unset_max_line_bytes(&mut self) -> &mut ParseConfig
pub fn unset_max_line_bytes(&mut self) -> &mut ParseConfig
Caps the size of a single NDJSON line. When the accumulated bytes for a single line
(i.e. between two \n characters) exceed this limit, the engine emits a parse error
and resynchronises to the next newline; subsequent lines can still be decoded.
None (the default) means no limit — appropriate only for trusted input sources.
Set this for any NDJSON stream sourced from an untrusted peer to avoid unbounded
memory growth from a peer that never sends a \n.
§Returns
A new config with all the same values as this one, except the max-line-bytes.
Trait Implementations§
§impl Clone for ParseConfig
impl Clone for ParseConfig
§fn clone(&self) -> ParseConfig
fn clone(&self) -> ParseConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for ParseConfig
impl Debug for ParseConfig
§impl Default for ParseConfig
impl Default for ParseConfig
§fn default() -> ParseConfig
fn default() -> ParseConfig
§impl Hash for ParseConfig
impl Hash for ParseConfig
§impl PartialEq for ParseConfig
impl PartialEq for ParseConfig
impl Copy for ParseConfig
impl Eq for ParseConfig
impl StructuralPartialEq for ParseConfig
Auto Trait Implementations§
impl Freeze for ParseConfig
impl RefUnwindSafe for ParseConfig
impl Send for ParseConfig
impl Sync for ParseConfig
impl Unpin for ParseConfig
impl UnsafeUnpin for ParseConfig
impl UnwindSafe for ParseConfig
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writer§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writer§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writer§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writer§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer