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: AThe attributes associated with the value.
value: TData content of the YSON node.
Trait Implementations§
Source§impl<T: Clone, A: Clone> Clone for WithAttributes<T, A>
impl<T: Clone, A: Clone> Clone for WithAttributes<T, A>
Source§fn clone(&self) -> WithAttributes<T, A>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Default, A: Default> Default for WithAttributes<T, A>
impl<T: Default, A: Default> Default for WithAttributes<T, A>
Source§fn default() -> WithAttributes<T, A>
fn default() -> WithAttributes<T, A>
Returns the “default value” for a type. Read more
Source§impl<V, A> Deref for WithAttributes<V, A>
impl<V, A> Deref for WithAttributes<V, A>
Source§impl<V, A> DerefMut for WithAttributes<V, A>
impl<V, A> DerefMut for WithAttributes<V, A>
Source§impl<'de, T, A> Deserialize<'de> for WithAttributes<T, A>where
T: Deserialize<'de>,
A: Deserialize<'de>,
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>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl<T: Eq, A: Eq> Eq for WithAttributes<T, A>
impl<T: PartialEq, A: PartialEq> StructuralPartialEq for WithAttributes<T, A>
Auto Trait Implementations§
impl<T, A> Freeze for WithAttributes<T, A>
impl<T, A> RefUnwindSafe for WithAttributes<T, A>where
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, A> Send for WithAttributes<T, A>
impl<T, A> Sync for WithAttributes<T, A>
impl<T, A> Unpin for WithAttributes<T, A>
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> 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