pub fn from_str<T>(s: &str) -> Result<T>where
T: for<'de> Deserialize<'de> + 'static,Expand description
Deserialize YAML from a &str into a typed T.
Default entry point for typed deserialisation. Drives the
streaming fast-path when the input matches its eligibility
rules (no custom merge-key policy, no ignore-binary-tag mode,
no registered policies); otherwise routes through the
Value-AST loader. The choice is transparent — both paths
produce identical results.
§Errors
Returns Error when:
Error::Parse/Error::ParseWithLocation—sis not well-formed YAML 1.2 (missing closing bracket, indentation mismatch, invalid escape, …).Error::Deserialize— the document parses but does not matchT’s shape (wrong scalar type, missing required field on a struct without#[serde(default)], unknown enum variant, …). A rejection inside a nested value names the field it is about —server.port: invalid type: string "x", expected u16— alongside the source location (#353).Error::DepthLimit/Error::DocumentTooLong/Error::AliasLimit— input exceeds the defaultParserConfigsafety budgets. Usefrom_str_with_configwithParserConfig::strict()for tighter limits or with relaxed limits if the defaults reject a known-good document.Error::DuplicateKey— only whenduplicate_key_policyhas been switched toError. The default policy isLast, which deduplicates without erroring.Error::Custom— surface for upstreamserde_core::de::Errorconversions; ordinarily the more specific variants above are produced first.
§Examples
let n: i32 = noyalib::from_str("42").unwrap();
assert_eq!(n, 42);