orientdb_client/common/types/
projection.rs1use crate::common::types::value::OValue;
2use std::collections::HashMap;
3use std::ops::{Deref, DerefMut};
4
5#[derive(Debug, PartialEq, Clone, Default)]
6pub struct Projection {
7 fields: HashMap<String, OValue>,
8}
9
10impl Projection {
11 pub fn as_str(&self, name: &str) -> Option<&str> {
12 match self.fields.get(name) {
13 Some(&OValue::String(ref v)) => Some(v),
14 Some(_) => None,
15 None => None,
16 }
17 }
18
19 pub fn take_map(self) -> HashMap<String, OValue> {
20 self.fields
21 }
22}
23
24impl Deref for Projection {
25 type Target = HashMap<String, OValue>;
26
27 fn deref(&self) -> &Self::Target {
28 &self.fields
29 }
30}
31
32impl DerefMut for Projection {
33 fn deref_mut(&mut self) -> &mut Self::Target {
34 &mut self.fields
35 }
36}