PartiqlMetadata

Struct PartiqlMetadata 

Source
pub struct PartiqlMetadata<T>
where T: Eq + Clone + Hash + Borrow<str>,
{ /* private fields */ }
Expand description

Provides a mean to store meta-data for PartiQL objects.

§Examples

use partiql_common::metadata::{PartiqlMetadata, PartiqlMetaValue};

let foo_val = PartiqlMetaValue::String("foo".to_string());
let i64_val = PartiqlMetaValue::Int64(2);///
let expected_vec_val = vec![foo_val, i64_val];

let expected_bool_val = true;///
let expected_int_val = 2;///
let expected_float_val = 2.5;///
let expected_str_val = "foo";///

let mut expected_map = PartiqlMetadata::new();///
expected_map.insert("bool value", expected_bool_val.into());///
expected_map.insert("integer value", expected_int_val.into());///

let mut metas = PartiqlMetadata::new();///
metas.insert("vec value", expected_vec_val.clone().into());
metas.insert("bool value", expected_bool_val.into());///
metas.insert("integer value", expected_int_val.into());///
metas.insert("float value", expected_float_val.into());///
metas.insert("string value", expected_str_val.into());///
metas.insert("map value", expected_map.clone().into());///

let vec_val = metas.vec_value("vec value").expect("vec meta value");///
let bool_val = metas.bool_value("bool value").expect("bool meta value");///
let int_val = metas.i32_value("integer value").expect("i32 meta value");///
let float_val = metas.f64_value("float value").expect("f64 meta value");///
let string_val = metas.string_value("string value").expect("string meta value");///
let map_val = metas.map_value("map value").expect("map meta value");///

assert_eq!(vec_val, expected_vec_val.clone());///
assert_eq!(bool_val, expected_bool_val.clone());///
assert_eq!(int_val, expected_int_val.clone());///
assert_eq!(float_val, expected_float_val.clone());///
assert_eq!(string_val, expected_str_val);///
assert_eq!(map_val, expected_map.clone());

Implementations§

Source§

impl<T> PartiqlMetadata<T>
where T: Eq + Clone + Hash + Borrow<str>,

Source

pub fn new() -> Self

Source

pub fn insert(&mut self, key: T, value: PartiqlMetaValue<T>)

Source

pub fn get(&self, key: &T) -> Option<&PartiqlMetaValue<T>>

Source

pub fn get_mut(&mut self, key: &T) -> Option<&mut PartiqlMetaValue<T>>

Source

pub fn contains_key(&self, key: &T) -> bool

Source

pub fn keys(&self) -> impl Iterator<Item = &T>

Source

pub fn values(&self) -> impl Iterator<Item = &PartiqlMetaValue<T>>

Source

pub fn values_mut(&mut self) -> impl Iterator<Item = &mut PartiqlMetaValue<T>>

Source

pub fn entry(&mut self, key: T) -> Entry<'_, T, PartiqlMetaValue<T>>

Source

pub fn clear(&mut self)

Source

pub fn remove(&mut self, key: &T) -> Option<PartiqlMetaValue<T>>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn iter(&self) -> impl Iterator<Item = (&T, &PartiqlMetaValue<T>)>

Source

pub fn iter_mut( &mut self, ) -> impl Iterator<Item = (&T, &mut PartiqlMetaValue<T>)>

Source

pub fn vec_value(&self, key: &str) -> Option<Vec<PartiqlMetaValue<T>>>

Source

pub fn bool_value(&self, key: &str) -> Option<bool>

Source

pub fn f32_value(&self, key: &str) -> Option<f32>

Source

pub fn f64_value(&self, key: &str) -> Option<f64>

Source

pub fn decimal_value(&self, key: &str) -> Option<Decimal>

Source

pub fn i32_value(&self, key: &str) -> Option<i32>

Source

pub fn i64_value(&self, key: &str) -> Option<i64>

Source

pub fn map_value(&self, key: &str) -> Option<PartiqlMetadata<T>>

Source

pub fn string_value(&self, key: &str) -> Option<String>

Trait Implementations§

Source§

impl<T> Clone for PartiqlMetadata<T>
where T: Eq + Clone + Hash + Borrow<str> + Clone,

Source§

fn clone(&self) -> PartiqlMetadata<T>

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<T> Debug for PartiqlMetadata<T>
where T: Eq + Clone + Hash + Borrow<str> + Debug,

Source§

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

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

impl<T> Default for PartiqlMetadata<T>
where T: Eq + Clone + Hash + Borrow<str>,

Source§

fn default() -> Self

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

impl<T> From<PartiqlMetadata<T>> for PartiqlMetaValue<T>
where T: Eq + Clone + Hash + Borrow<str>,

Source§

fn from(value: PartiqlMetadata<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> FromIterator<(T, PartiqlMetaValue<T>)> for PartiqlMetadata<T>
where T: Eq + Clone + Hash + Borrow<str>,

Source§

fn from_iter<I: IntoIterator<Item = (T, PartiqlMetaValue<T>)>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T> IntoIterator for PartiqlMetadata<T>
where T: Eq + Clone + Hash + Borrow<str>,

Source§

type Item = (T, PartiqlMetaValue<T>)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T, PartiqlMetaValue<T>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> PartialEq for PartiqlMetadata<T>
where T: Eq + Clone + Hash + Borrow<str> + PartialEq,

Source§

fn eq(&self, other: &PartiqlMetadata<T>) -> 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<T> StructuralPartialEq for PartiqlMetadata<T>
where T: Eq + Clone + Hash + Borrow<str>,

Auto Trait Implementations§

§

impl<T> Freeze for PartiqlMetadata<T>

§

impl<T> RefUnwindSafe for PartiqlMetadata<T>
where T: RefUnwindSafe,

§

impl<T> Send for PartiqlMetadata<T>
where T: Send,

§

impl<T> Sync for PartiqlMetadata<T>
where T: Sync,

§

impl<T> Unpin for PartiqlMetadata<T>
where T: Unpin,

§

impl<T> UnwindSafe for PartiqlMetadata<T>
where 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> 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, Loc> ToLocated<Loc> for T
where Loc: Display,

Source§

fn to_located<IntoLoc>(self, location: IntoLoc) -> Located<Self, Loc>
where IntoLoc: Into<Location<Loc>>,

Create a Located from its inner value.
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.