pub fn parse_adapter_block(
header_name: Option<&str>,
content: &str,
) -> Result<AdapterDef, ConfigError>Expand description
Parses an adapter YAML fence block into an AdapterDef.
The function deserializes content as YAML, determines the adapter name using
the fence header if present (erroring on conflicts or absence), validates the
adapter configuration, and converts it into an AdapterDef.
§Errors
Returns a ConfigError when:
- YAML deserialization fails (
ConfigError::YamlParse), - both a header name and a payload name are provided (
ConfigError::NameConflict), - no name is provided (
ConfigError::MissingName), - the adapter type is unrecognized (
ConfigError::UnknownAdapter), - or other validation failures occur.
§Examples
use cellstate_pipeline::parse_adapter_block;
let header = Some("my_adapter");
let yaml = r#"
adapter_type: "postgres"
connection: "postgres://user:pass@localhost/db"
options: []
"#;
let def = parse_adapter_block(header, yaml).expect("should parse");
assert_eq!(def.name, "my_adapter");