Files
VoelinClient/crates/proto/ts-bookkeeping/build/Properties.tt
T
Claude 7b6959c4cc vendor: import ReSpeak/tsclientlib@ee3bc6f
Unmodified copy of the tsclientlib workspace crates (MIT OR Apache-2.0)
with the tsdeclarations submodule (83cb8a9) flattened into plain files.
See crates/proto/UPSTREAM.md for the path mapping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-25 12:46:11 +00:00

56 lines
1.9 KiB
Plaintext

<#@ template cleanws="true" #>
impl Connection {
/// Get a property by its id.
pub fn get_property(&self, id: &PropertyId) -> Result<PropertyValueRef<'_>> {
Ok(match id {
<# for struc in &self.0.structs {
let mut ids = embrace(&get_ids(struc));
let mut ids2 = get_ids2(&self.0.structs, struc);
ids2 = format!("({})", ids2); #>
PropertyId::<#= struc.name #><#= ids #> => PropertyValueRef::<#= struc.name #>(self.get_<#= struc.name.to_snake_case() #><#= ids2 #>?),
<# } #>
<# for struc in self.0.structs.iter().filter(|s| !s.opt) {
for p in struc.get_properties(&self.0.structs) {
let type_s = p.get_inner_type_as_name()?;
let mut ids = get_ids(struc);
if p.modifier.is_some() {
if !ids.is_empty() {
ids.push_str(", ");
}
ids.push_str("m");
}
ids = embrace(&ids);
let mut ids2 = format!("({})", get_ids2(&self.0.structs, struc));
#>
PropertyId::<#= struc.name #><#= p.get_name() #><#= ids
#> => PropertyValueRef::<#= type_s #>(self.get_<#=
struc.name.to_snake_case() #><#= ids2 #>?.<#=
p.name.to_snake_case() #><#
if p.modifier.as_ref().map(|s| s == "map").unwrap_or(false) {
#>.get(*m)
.ok_or_else(|| Error::NotFound("<#= p.name #>", m.to_string()))?<#
} else if p.modifier.as_ref().map(|s| s == "array").unwrap_or(false) {
#>.iter()<#
if p.type_s != "str" { #>.cloned().find(|i| i == m)<#
} else { #>.find(|i| *i == m)<# } #>
.ok_or_else(|| Error::NotFound("<#= p.name #>", m.to_string()))?<#
} else if p.modifier.as_ref().map(|s| s == "set").unwrap_or(false) {
#>.get(m)<#
if p.type_s != "str" { #>.cloned()<# } #>
.ok_or_else(|| Error::NotFound("<#= p.name #>", m.to_string()))?<#
}
if p.opt && (p.type_s == "str" || p.type_s == "Uid") {
#>.as_ref().map(|r| r.as_ref())<#
} else if p.type_s == "str" || p.type_s == "Uid" || ["TalkPowerRequest", "EccKeyPubP256"].contains(&p.type_s.as_str()) {
#>.as_ref()<#
} #>),
<# }
} #>
})
}
}