Skip to repository content38 lines · 1.1 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T01:41:02.277Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
serde_helpers.rs
1use serde::de::{self, Deserializer, Visitor};
2use std::fmt;
3
4/// Deserializes a non-empty string array.
5pub fn non_empty_string_vec<'de, D>(deserializer: D) -> Result<Vec<String>, D::Error>
6where
7 D: Deserializer<'de>,
8{
9 struct NonEmptyStringVecVisitor;
10
11 impl<'de> Visitor<'de> for NonEmptyStringVecVisitor {
12 type Value = Vec<String>;
13
14 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
15 formatter.write_str("a list of non-empty strings")
16 }
17
18 fn visit_seq<V>(self, mut seq: V) -> Result<Vec<String>, V::Error>
19 where
20 V: de::SeqAccess<'de>,
21 {
22 let mut vec = Vec::new();
23 while let Some(value) = seq.next_element::<String>()? {
24 if value.is_empty() {
25 return Err(de::Error::invalid_value(
26 de::Unexpected::Str(&value),
27 &"a non-empty string",
28 ));
29 }
30 vec.push(value);
31 }
32 Ok(vec)
33 }
34 }
35
36 deserializer.deserialize_seq(NonEmptyStringVecVisitor)
37}
38