Skip to content

Commit

Permalink
Also update property_many, property_with_cardinality, and property_ma…
Browse files Browse the repository at this point in the history
…ny_with_cardinality to take a Key that impls Into<GValue> instead of just &str
  • Loading branch information
criminosis committed Jul 17, 2024
1 parent 97b677c commit f0115d2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
16 changes: 9 additions & 7 deletions gremlin-client/src/process/traversal/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ impl TraversalBuilder {
self
}

pub fn property_many<A>(mut self, values: Vec<(String, A)>) -> Self
pub fn property_many<K, V>(mut self, values: Vec<(K, V)>) -> Self
where
A: Into<GValue>,
K: Into<GValue>,
V: Into<GValue>,
{
for property in values {
self.bytecode.add_step(
Expand All @@ -116,18 +117,19 @@ impl TraversalBuilder {
self
}

pub fn property_with_cardinality<A>(
pub fn property_with_cardinality<K, V>(
mut self,
cardinality: Cardinality,
key: &str,
value: A,
key: K,
value: V,
) -> Self
where
A: Into<GValue>,
K: Into<GValue>,
V: Into<GValue>,
{
self.bytecode.add_step(
String::from("property"),
vec![cardinality.into(), String::from(key).into(), value.into()],
vec![cardinality.into(), key.into(), value.into()],
);
self
}
Expand Down
32 changes: 15 additions & 17 deletions gremlin-client/src/process/traversal/graph_traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,45 +103,43 @@ impl<S, E: FromGValue, T: Terminator<E>> GraphTraversal<S, E, T> {
self
}

pub fn property_with_cardinality<A>(
pub fn property_with_cardinality<K, V>(
mut self,
cardinality: Cardinality,
key: &str,
value: A,
key: K,
value: V,
) -> Self
where
A: Into<GValue>,
K: Into<GValue>,
V: Into<GValue>,
{
self.builder = self
.builder
.property_with_cardinality(cardinality, key, value);
self
}

pub fn property_many<A>(mut self, values: Vec<(String, A)>) -> Self
pub fn property_many<K, V>(mut self, values: Vec<(K, V)>) -> Self
where
A: Into<GValue>,
K: Into<GValue>,
V: Into<GValue>,
{
for property in values {
self.builder = self
.builder
.property::<&str, A>(property.0.as_ref(), property.1)
self.builder = self.builder.property(property.0, property.1)
}

self
}

pub fn property_many_with_cardinality<A>(
mut self,
values: Vec<(Cardinality, String, A)>,
) -> Self
pub fn property_many_with_cardinality<K, V>(mut self, values: Vec<(Cardinality, K, V)>) -> Self
where
A: Into<GValue>,
K: Into<GValue>,
V: Into<GValue>,
{
for property in values {
self.builder =
self.builder
.property_with_cardinality(property.0, property.1.as_ref(), property.2);
self.builder = self
.builder
.property_with_cardinality(property.0, property.1, property.2);
}

self
Expand Down

0 comments on commit f0115d2

Please sign in to comment.