pub struct DetailedField<V, D> { /* private fields */ }Expand description
A field with an optional detailed representation
Many feed fields follow the pattern of having a simple value (like a string) and an optional detailed struct with additional metadata. This generic wrapper captures that pattern.
§Type Parameters
V- The simple value type (usuallyString)D- The detailed representation type (e.g.,TextConstruct,Person)
§Examples
use feedparser_rs::types::generics::DetailedField;
// Simple value only
let title: DetailedField<String, ()> = DetailedField::from_value("My Title".to_string());
assert_eq!(title.value(), "My Title");
assert!(title.detail().is_none());
// With detail
let title = DetailedField::with_detail("My Title".to_string(), "extra info");
assert_eq!(title.detail(), Some(&"extra info"));Implementations§
Source§impl<V, D> DetailedField<V, D>
impl<V, D> DetailedField<V, D>
Sourcepub const fn from_value(value: V) -> Self
pub const fn from_value(value: V) -> Self
Create a field with only a simple value
Sourcepub const fn with_detail(value: V, detail: D) -> Self
pub const fn with_detail(value: V, detail: D) -> Self
Create a field with both value and detail
Sourcepub const fn detail_mut(&mut self) -> Option<&mut D>
pub const fn detail_mut(&mut self) -> Option<&mut D>
Get mutable reference to the detail if present
Sourcepub fn set_detail(&mut self, detail: D)
pub fn set_detail(&mut self, detail: D)
Set the detail
Sourcepub const fn take_detail(&mut self) -> Option<D>
pub const fn take_detail(&mut self) -> Option<D>
Take the detail, leaving None in its place
Sourcepub fn into_parts(self) -> (V, Option<D>)
pub fn into_parts(self) -> (V, Option<D>)
Convert into a tuple of (value, Option<detail>)
Trait Implementations§
Source§impl<V: Clone, D: Clone> Clone for DetailedField<V, D>
impl<V: Clone, D: Clone> Clone for DetailedField<V, D>
Source§fn clone(&self) -> DetailedField<V, D>
fn clone(&self) -> DetailedField<V, D>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<V: Default, D> Default for DetailedField<V, D>
impl<V: Default, D> Default for DetailedField<V, D>
Source§impl<V, D> From<(V, D)> for DetailedField<V, D>
impl<V, D> From<(V, D)> for DetailedField<V, D>
Source§impl<V, D> From<V> for DetailedField<V, D>
impl<V, D> From<V> for DetailedField<V, D>
impl<V: Eq, D: Eq> Eq for DetailedField<V, D>
impl<V, D> StructuralPartialEq for DetailedField<V, D>
Auto Trait Implementations§
impl<V, D> Freeze for DetailedField<V, D>
impl<V, D> RefUnwindSafe for DetailedField<V, D>where
V: RefUnwindSafe,
D: RefUnwindSafe,
impl<V, D> Send for DetailedField<V, D>
impl<V, D> Sync for DetailedField<V, D>
impl<V, D> Unpin for DetailedField<V, D>
impl<V, D> UnwindSafe for DetailedField<V, D>where
V: UnwindSafe,
D: UnwindSafe,
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