Skip to main content

Attribute

Struct Attribute 

Source
pub struct Attribute<'a, Spec: Specification = Raw> {
    pub name: Name<'a, Spec>,
    pub value: Value<'a, Spec>,
}
Expand description

An attribute of an Object.

§Example

let object = parse_object("
name:           ACME Company

")?;
let attribute = Attribute::new("name", "ACME Company");
assert_eq!(object[0], attribute);

Fields§

§name: Name<'a, Spec>

The name of the attribute.

§value: Value<'a, Spec>

The value of the attribute.

Implementations§

Source§

impl<'a, Spec: Specification> Attribute<'a, Spec>

Source

pub fn new<N, V>(name: N, value: V) -> Self
where N: Into<Name<'a, Spec>>, V: Into<Value<'a, Spec>>,

Create a new attribute.

Source

pub fn validate<TargetSpec: Specification>(&self) -> Result<(), AttributeError>

Validate that the attribute conforms to a target specification.

§Errors

Returns an AttributeError if the attribute does not conform to the target specification.

Source

pub fn into_spec<TargetSpec: Specification>( self, ) -> Result<Attribute<'a, TargetSpec>, AttributeError>

Convert the attribute into a target specification.

§Errors

Returns an AttributeError if the attribute does not conform to the target specification.

Source

pub fn into_owned(self) -> Attribute<'static, Spec>

Convert this attribute into an owned ('static) variant.

Trait Implementations§

Source§

impl<'a, Spec: Clone + Specification> Clone for Attribute<'a, Spec>

Source§

fn clone(&self) -> Attribute<'a, Spec>

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<'a, Spec: Debug + Specification> Debug for Attribute<'a, Spec>

Source§

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

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

impl<Spec: Specification> Display for Attribute<'_, Spec>

Source§

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

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

impl<'a, Spec: PartialEq + Specification> PartialEq for Attribute<'a, Spec>

Source§

fn eq(&self, other: &Attribute<'a, Spec>) -> 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<'a, Spec: Specification> Serialize for Attribute<'a, Spec>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a, Spec: Eq + Specification> Eq for Attribute<'a, Spec>

Source§

impl<'a, Spec: Specification> StructuralPartialEq for Attribute<'a, Spec>

Auto Trait Implementations§

§

impl<'a, Spec> Freeze for Attribute<'a, Spec>

§

impl<'a, Spec> RefUnwindSafe for Attribute<'a, Spec>
where Spec: RefUnwindSafe,

§

impl<'a, Spec> Send for Attribute<'a, Spec>
where Spec: Send,

§

impl<'a, Spec> Sync for Attribute<'a, Spec>
where Spec: Sync,

§

impl<'a, Spec> Unpin for Attribute<'a, Spec>
where Spec: Unpin,

§

impl<'a, Spec> UnwindSafe for Attribute<'a, Spec>
where Spec: 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<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.