pub fn parse_data_uri(
value: &str,
field_name: &str,
) -> Result<DataUriContent, Error>Expand description
Parse a data URI and extract its content
Parses data URIs in the format data:<mime>;base64,<content>.
Only base64 encoding is supported.
§Arguments
value- The data URI string to parsefield_name- The name of the field (used in error messages)
§Returns
Returns DataUriContent with the extracted MIME type and decoded bytes.
§Errors
Returns an error if:
- The data URI format is invalid
- The encoding is not base64
- The base64 content cannot be decoded
§Example
use rmcp_openapi::http_client::parse_data_uri;
let uri = "data:image/png;base64,iVBORw0KGgo=";
let content = parse_data_uri(uri, "image_field").unwrap();
assert_eq!(content.mime_type, "image/png");