Skip to main content

WithAttributes

Struct WithAttributes 

Source
pub struct WithAttributes<T, A> {
    pub attributes: A,
    pub value: T,
}
Expand description

Wrapper that pairs a value of type T with its associated YSON attributes of type A

Any value can have optional map of attributes

§Examples

use ytsaurus_yson::{WithAttributes, from_slice, YsonFormat};
use std::collections::BTreeMap;

// YSON: <author="Alice">"Hello"
let input = b"<author=\"Alice\">\"Hello\"";

// Define a value where attributes are a BTreeMap and the content is a String
type MyNode = WithAttributes<String, BTreeMap<String, String>>;

let node: MyNode = from_slice(input, YsonFormat::Text).unwrap();

// Access attributes
assert_eq!(node.attributes.get("author").unwrap(), "Alice");

// Access inner value directly via Deref or .value
assert_eq!(node.value, "Hello");
assert_eq!(*node, "Hello");

Fields§

§attributes: A

The attributes associated with the value.

§value: T

Data content of the YSON node.

Trait Implementations§

Source§

impl<T: Clone, A: Clone> Clone for WithAttributes<T, A>

Source§

fn clone(&self) -> WithAttributes<T, A>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, A: Debug> Debug for WithAttributes<T, A>

Source§

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

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

impl<T: Default, A: Default> Default for WithAttributes<T, A>

Source§

fn default() -> WithAttributes<T, A>

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

impl<V, A> Deref for WithAttributes<V, A>

Source§

type Target = V

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<V, A> DerefMut for WithAttributes<V, A>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'de, T, A> Deserialize<'de> for WithAttributes<T, A>
where T: Deserialize<'de>, A: Deserialize<'de>,

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: Eq, A: Eq> Eq for WithAttributes<T, A>

Source§

impl<T: PartialEq, A: PartialEq> PartialEq for WithAttributes<T, A>

Source§

fn eq(&self, other: &WithAttributes<T, A>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T: Serialize, A: Serialize> Serialize for WithAttributes<T, A>

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

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

impl<T: PartialEq, A: PartialEq> StructuralPartialEq for WithAttributes<T, A>

Auto Trait Implementations§

§

impl<T, A> Freeze for WithAttributes<T, A>
where A: Freeze, T: Freeze,

§

impl<T, A> RefUnwindSafe for WithAttributes<T, A>

§

impl<T, A> Send for WithAttributes<T, A>
where A: Send, T: Send,

§

impl<T, A> Sync for WithAttributes<T, A>
where A: Sync, T: Sync,

§

impl<T, A> Unpin for WithAttributes<T, A>
where A: Unpin, T: Unpin,

§

impl<T, A> UnsafeUnpin for WithAttributes<T, A>
where A: UnsafeUnpin, T: UnsafeUnpin,

§

impl<T, A> UnwindSafe for WithAttributes<T, A>
where A: UnwindSafe, T: 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.