From 2b57e045de6f4a588f1aea58a5d616199dec4cfb Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 19 Feb 2026 23:11:18 +0100 Subject: query parser --- common/object/src/path.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'common/object/src/path.rs') diff --git a/common/object/src/path.rs b/common/object/src/path.rs index 0751ff0..4779cd5 100644 --- a/common/object/src/path.rs +++ b/common/object/src/path.rs @@ -5,7 +5,7 @@ */ use crate::{Object, Tag, TypedTag}; -use std::{fmt::Display, marker::PhantomData}; +use std::{fmt::Display, marker::PhantomData, str::FromStr}; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Path(pub Vec); @@ -48,3 +48,19 @@ impl Display for Path { Ok(()) } } +impl FromStr for Path { + type Err = &'static str; + fn from_str(s: &str) -> Result { + Ok(Self( + s.split(".") + .map(|e| { + e.as_bytes() + .try_into() + .map_err(|_| "path component not 4 bytes") + .map(Tag::new) + }) + .collect::, &'static str>>()?, + )) + } +} + -- cgit v1.3