DetailedField

Struct DetailedField 

Source
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 (usually String)
  • 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>

Source

pub const fn from_value(value: V) -> Self

Create a field with only a simple value

Source

pub const fn with_detail(value: V, detail: D) -> Self

Create a field with both value and detail

Source

pub const fn value(&self) -> &V

Get reference to the simple value

Source

pub const fn value_mut(&mut self) -> &mut V

Get mutable reference to the simple value

Source

pub const fn detail(&self) -> Option<&D>

Get reference to the detail if present

Source

pub const fn detail_mut(&mut self) -> Option<&mut D>

Get mutable reference to the detail if present

Source

pub fn set_detail(&mut self, detail: D)

Set the detail

Source

pub const fn take_detail(&mut self) -> Option<D>

Take the detail, leaving None in its place

Source

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>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug, D: Debug> Debug for DetailedField<V, D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Default, D> Default for DetailedField<V, D>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<V, D> From<(V, D)> for DetailedField<V, D>

Source§

fn from((value, detail): (V, D)) -> Self

Converts to this type from the input type.
Source§

impl<V, D> From<V> for DetailedField<V, D>

Source§

fn from(value: V) -> Self

Converts to this type from the input type.
Source§

impl<V: PartialEq, D: PartialEq> PartialEq for DetailedField<V, D>

Source§

fn eq(&self, other: &DetailedField<V, D>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: Eq, D: Eq> Eq for DetailedField<V, D>

Source§

impl<V, D> StructuralPartialEq for DetailedField<V, D>

Auto Trait Implementations§

§

impl<V, D> Freeze for DetailedField<V, D>
where V: Freeze, D: Freeze,

§

impl<V, D> RefUnwindSafe for DetailedField<V, D>

§

impl<V, D> Send for DetailedField<V, D>
where V: Send, D: Send,

§

impl<V, D> Sync for DetailedField<V, D>
where V: Sync, D: Sync,

§

impl<V, D> Unpin for DetailedField<V, D>
where V: Unpin, D: Unpin,

§

impl<V, D> UnwindSafe for DetailedField<V, D>
where V: UnwindSafe, D: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more