pub enum ReturnValue {
Array(Vec<ReturnValue>),
Object(HashMap<String, ReturnValue>),
Value(Value),
Empty,
}
Expand description
A return value enum that represents different possible outputs from graph operations. Can contain traversal results, counts, boolean flags, or empty values.
Variants§
Implementations§
Source§impl ReturnValue
impl ReturnValue
pub fn from_properties(properties: HashMap<String, Value>) -> Self
pub fn from_traversal_value_array_with_mixin( traversal_value: Vec<TraversalVal>, mixin: RefMut<'_, HashMap<u128, ResponseRemapping>>, ) -> Self
pub fn from_traversal_value_with_mixin( traversal_value: TraversalVal, mixin: RefMut<'_, HashMap<u128, ResponseRemapping>>, ) -> Self
pub fn mixin(self, other: ReturnValue) -> Self
Sourcepub fn mixin_remapping(self, remappings: HashMap<String, Remapping>) -> Self
pub fn mixin_remapping(self, remappings: HashMap<String, Remapping>) -> Self
Mixin a remapping to a return value.
This function takes a hashmap of Remappings
and mixes them into the return value
- If the mapping is an exclude, then the key is removed from the return value
- If the mapping is a remapping from an old value to a new value, then the key is replaced with the new name and the value is the new value
- If the mapping is a new mapping, then the key is added to the return value and the value is the new value
- Otherwise, the key is left unchanged and the value is the original value
Basic usage:
use helix_db::protocol::{ReturnValue, Remapping};
use std::collections::HashMap;
let remappings = HashMap::new();
remappings.insert(
"old_key".to_string(),
Remapping::new(
Some("new_key".to_string()),
ReturnValue::from("new_value".to_string())
)
);
let return_value = ReturnValue::from("old_value".to_string());
let return_value = return_value.mixin_remapping(remappings);
assert_eq!(
return_value.get("new_key".to_string()),
Some(&ReturnValue::from("new_value".to_string()))
);
pub fn mixin_other<I>(
&self,
item: I,
secondary_properties: ResponseRemapping,
) -> Selfwhere
I: Filterable + Clone,
Trait Implementations§
Source§impl Clone for ReturnValue
impl Clone for ReturnValue
Source§fn clone(&self) -> ReturnValue
fn clone(&self) -> ReturnValue
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ReturnValue
impl Debug for ReturnValue
Source§impl Default for ReturnValue
impl Default for ReturnValue
Source§impl<'de> Deserialize<'de> for ReturnValue
impl<'de> Deserialize<'de> for ReturnValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&[f64]> for ReturnValue
impl From<&[f64]> for ReturnValue
Source§impl From<&Value> for ReturnValue
impl From<&Value> for ReturnValue
Source§impl From<&str> for ReturnValue
impl From<&str> for ReturnValue
Source§impl From<Count> for ReturnValue
impl From<Count> for ReturnValue
Source§impl<I> From<I> for ReturnValuewhere
I: Filterable + Clone,
impl<I> From<I> for ReturnValuewhere
I: Filterable + Clone,
Source§impl From<String> for ReturnValue
impl From<String> for ReturnValue
Source§impl From<TraversalVal> for ReturnValue
impl From<TraversalVal> for ReturnValue
Source§fn from(val: TraversalVal) -> Self
fn from(val: TraversalVal) -> Self
Converts to this type from the input type.
Source§impl From<Value> for ReturnValue
impl From<Value> for ReturnValue
Source§impl From<Vec<TraversalVal>> for ReturnValue
impl From<Vec<TraversalVal>> for ReturnValue
Source§fn from(array: Vec<TraversalVal>) -> Self
fn from(array: Vec<TraversalVal>) -> Self
Converts to this type from the input type.
Source§impl From<bool> for ReturnValue
impl From<bool> for ReturnValue
Source§impl From<f64> for ReturnValue
impl From<f64> for ReturnValue
Source§impl From<i32> for ReturnValue
impl From<i32> for ReturnValue
Source§impl From<u128> for ReturnValue
impl From<u128> for ReturnValue
Source§impl PartialEq for ReturnValue
impl PartialEq for ReturnValue
Source§impl Serialize for ReturnValue
impl Serialize for ReturnValue
impl StructuralPartialEq for ReturnValue
Auto Trait Implementations§
impl Freeze for ReturnValue
impl RefUnwindSafe for ReturnValue
impl Send for ReturnValue
impl Sync for ReturnValue
impl Unpin for ReturnValue
impl UnwindSafe for ReturnValue
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more