pub fn parse_memory_block(
header_name: Option<&str>,
content: &str,
) -> Result<MemoryDef, ConfigError>Expand description
Parses a YAML memory block (fence content) into a MemoryDef.
The header-provided name takes precedence when the payload omits a name. If both header and payload provide names, or if neither provides a name, an error is returned. Returns an error for invalid YAML or any invalid/unknown values found during conversion.
§Errors
Returns ConfigError::YamlParse if the content is not valid YAML; ConfigError::NameConflict
if both header and payload specify different names; ConfigError::MissingName if no name is provided;
or other ConfigError variants produced by value parsing helpers when fields contain invalid values.
§Examples
use cellstate_pipeline::parse_memory_block;
let yaml = r#"
memory_type: episodic
retention: persistent
lifecycle: explicit
schema:
- name: id
field_type: uuid
- name: content
field_type: text
indexes: []
inject_on: []
modifiers: []
"#;
let def = parse_memory_block(Some("my_memory"), yaml).unwrap();
assert_eq!(def.name, "my_memory");