pub fn from_str_with_config<T>(s: &str, config: &ParserConfig) -> Result<T>where
T: for<'de> Deserialize<'de> + 'static,Expand description
Deserialize YAML from a &str with a custom ParserConfig.
Use this when the defaults need overriding — common reasons:
untrusted input (ParserConfig::strict()), pipeline-specific
limits (ParserConfig::max_depth), YAML 1.1 compatibility
(ParserConfig::version), or custom safe-YAML
policy::Policy enforcement.
§Errors
Same variant set as from_str. The active config controls
which limit-related errors can fire:
- When
config.duplicate_key_policy == DuplicateKeyPolicy::Error, any duplicate mapping key returnsError::DuplicateKey. - When the input exceeds the configured
max_depth,max_document_length,max_alias_expansions,max_mapping_keys, ormax_sequence_length, the matchingError::*Limitvariant is returned. - When
config.policiescontains a policy that rejects the document,Error::Deserializeis returned with the policy’s diagnostic.
§Examples
use noyalib::{from_str_with_config, ParserConfig};
let cfg = ParserConfig::strict();
let n: i32 = from_str_with_config("7", &cfg).unwrap();
assert_eq!(n, 7);