pub trait ParseFrom<Source>: Sized {
// Required method
fn parse_from(source: Source) -> Option<Self>;
}Expand description
Generic trait for parsing types from various sources using GAT
This trait provides a unified interface for constructing types from different data sources (JSON values, XML elements, etc.) using Generic Associated Types (GAT) for flexible lifetime handling.
§Examples
use feedparser_rs::types::generics::ParseFrom;
use feedparser_rs::types::Person;
use serde_json::json;
let json = json!({"name": "John Doe", "url": "https://example.com"});
let person = Person::parse_from(&json);
assert!(person.is_some());
assert_eq!(person.unwrap().name.as_deref(), Some("John Doe"));Required Methods§
Sourcefn parse_from(source: Source) -> Option<Self>
fn parse_from(source: Source) -> Option<Self>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.