MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / value_to_string

Method value_to_string

gql-cli/src/cli/output.rs:156–194  ·  view source on GitHub ↗

Convert a Value to a display string

(value: &Value)

Source from the content-addressed store, hash-verified

154
155 /// Convert a Value to a display string
156 fn value_to_string(value: &Value) -> String {
157 match value {
158 Value::String(s) => s.clone(),
159 Value::Number(n) => n.to_string(),
160 Value::Boolean(b) => b.to_string(),
161 Value::Null => "NULL".to_string(),
162 Value::DateTime(dt) => dt.to_string(),
163 Value::DateTimeWithFixedOffset(dt) => dt.to_string(),
164 Value::DateTimeWithNamedTz(tz, dt) => format!("{} {}", dt, tz),
165 Value::TimeWindow(tw) => format!("TIME_WINDOW({} to {})", tw.start, tw.end),
166 Value::Path(path) => format!("{:?}", path),
167 Value::Array(arr) | Value::List(arr) => format!(
168 "[{}]",
169 arr.iter()
170 .map(Self::value_to_string)
171 .collect::<Vec<_>>()
172 .join(", ")
173 ),
174 Value::Vector(vec) => format!(
175 "VECTOR[{}]",
176 vec.iter()
177 .map(|v| v.to_string())
178 .collect::<Vec<_>>()
179 .join(", ")
180 ),
181 Value::Node(node) => {
182 let labels = if node.labels.is_empty() {
183 String::new()
184 } else {
185 format!(":{}", node.labels.join(":"))
186 };
187 format!("({}{})", node.id, labels)
188 }
189 Value::Edge(edge) => {
190 format!("[{}:{}]", edge.id, edge.label)
191 }
192 Value::Temporal(temporal) => format!("TEMPORAL({:?})", temporal),
193 }
194 }
195
196 /// Convert a Value to a JSON value
197 fn value_to_json(value: &Value) -> serde_json::Value {

Callers

nothing calls this directly

Calls 2

cloneMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected