#[non_exhaustive]pub struct ParseLimits {
pub max_block_bytes: usize,
pub max_depth: usize,
}Expand description
Resource limits applied while a front-matter block is parsed.
Front matter is untrusted input in any pipeline that ingests contributed documents, so every parse runs under a budget. The defaults are the YAML parser’s strict preset narrowed to what a document header plausibly needs; raise them with the builder methods for manifests that are genuinely large.
§Example
use metadata_gen::{extract_metadata_with_limits, ParseLimits};
let limits = ParseLimits::default().max_block_bytes(4096);
let err = extract_metadata_with_limits(
&format!("---\ntitle: {}\n---\n", "x".repeat(5000)),
&limits,
)
.unwrap_err();
assert!(err.to_string().contains("exceeds"));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_block_bytes: usizeLargest front-matter block, in bytes, that will be handed to a parser.
max_depth: usizeDeepest nesting of mappings and sequences the YAML parser accepts.
Implementations§
Source§impl ParseLimits
impl ParseLimits
Trait Implementations§
Source§impl Clone for ParseLimits
impl Clone for ParseLimits
impl Copy for ParseLimits
Source§impl Debug for ParseLimits
impl Debug for ParseLimits
Source§impl Default for ParseLimits
impl Default for ParseLimits
impl Eq for ParseLimits
Source§impl PartialEq for ParseLimits
impl PartialEq for ParseLimits
impl StructuralPartialEq for ParseLimits
Auto Trait Implementations§
impl Freeze for ParseLimits
impl RefUnwindSafe for ParseLimits
impl Send for ParseLimits
impl Sync for ParseLimits
impl Unpin for ParseLimits
impl UnsafeUnpin for ParseLimits
impl UnwindSafe for ParseLimits
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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
Checks if this value is equivalent to the given key. Read more
§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
Compare self to
key and return true if they are equal.