MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / from_str_normalized

Method from_str_normalized

atomic-agent/src/turn/phase.rs:144–152  ·  view source on GitHub ↗

Normalize a string to a Phase, defaulting to `Idle` for unknown values. This provides backward compatibility with session state files that may have empty or unrecognized phase values. # Example ```rust use atomic_agent::turn::phase::Phase; assert_eq!(Phase::from_str_normalized("active"), Phase::Active); assert_eq!(Phase::from_str_normalized(""), Phase::Idle); assert_eq!(Phase::from_str_normali

(s: &str)

Source from the content-addressed store, hash-verified

142 /// assert_eq!(Phase::from_str_normalized("garbage"), Phase::Idle);
143 /// ```
144 pub fn from_str_normalized(s: &str) -> Self {
145 match s {
146 "idle" => Phase::Idle,
147 "active" => Phase::Active,
148 "active_recorded" => Phase::ActiveRecorded,
149 "ended" => Phase::Ended,
150 _ => Phase::Idle,
151 }
152 }
153
154 /// Returns the canonical string representation.
155 pub fn as_str(&self) -> &'static str {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected