Parse text representation into a Claw value.
(input: &core::ffi::CStr)
| 72 | impl InOutFuncs for Claw { |
| 73 | /// Parse text representation into a Claw value. |
| 74 | fn input(input: &core::ffi::CStr) -> Self |
| 75 | where |
| 76 | Self: Sized, |
| 77 | { |
| 78 | let s = input.to_str().expect("invalid UTF-8 in claw input"); |
| 79 | let s = s.trim(); |
| 80 | |
| 81 | if let Some(rest) = s.strip_prefix("agent:") { |
| 82 | // agent:id or agent:id:model |
| 83 | let parts: Vec<&str> = rest.splitn(2, ':').collect(); |
| 84 | let agent_id = parts[0].to_string(); |
| 85 | let model_override = parts.get(1).map(|s| s.to_string()); |
| 86 | Claw::agent_ref(agent_id, model_override) |
| 87 | } else if let Some(colon_pos) = s.find(':') { |
| 88 | // Check if there's a space before the colon — if so, it's just a prompt |
| 89 | let before_colon = &s[..colon_pos]; |
| 90 | if before_colon.contains(' ') { |
| 91 | Claw::inline(s.to_string(), None) |
| 92 | } else { |
| 93 | let model = before_colon.to_string(); |
| 94 | let prompt = s[colon_pos + 1..].to_string(); |
| 95 | Claw::inline(prompt, Some(model)) |
| 96 | } |
| 97 | } else { |
| 98 | Claw::inline(s.to_string(), None) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /// Convert Claw value to text representation. |
| 103 | fn output(&self, buffer: &mut pgrx::StringInfo) { |
nothing calls this directly
no outgoing calls
no test coverage detected