Skip to main content

decode

Function decode 

Source
pub fn decode(raw: &str) -> Result<Cow<'_, str>, NameError>
Expand description

Decode a raw Mcp-Name header value to the name the body actually carries.

A plain value is returned borrowed, so the common path allocates nothing. Only the sentinel form allocates, and only because it must.

A value that opens with the prefix but does not close with the suffix is treated as a literal rather than an error: it is not wearing the complete sentinel, so by the spec’s own encoding rule it cannot be an encoded value.

§Errors

Returns NameError when the value wears both markers but the payload between them is not Base64-encoded UTF-8.