pub fn resolve_chart_format(
explicit_format: Option<&str>,
output_path: Option<&str>,
) -> Result<ChartFormat, McpError>Expand description
Resolve the effective output format from an explicit format parameter
and/or an output_path’s extension.
Rules:
- Both set: they must agree. Conflict returns
InvalidArgumentnaming both values so the caller can fix one. - Only
formatset: parse it viaChartFormat::parse. - Only
output_pathset: derive from its extension (.png/.svg). Unknown extensions returnInvalidArgument. - Neither set: default to PNG (matches the pre-change behavior).
The path is only inspected for its extension — the file need not exist.
§Errors
- Returns
ErrorCode::InvalidArgumentif bothexplicit_formatandoutput_pathare set and they disagree on the format. - Propagates
ErrorCode::UnsupportedFormatfromChartFormat::parsefor unknown format strings. - Returns
ErrorCode::InvalidArgument(viaformat_from_extension) whenoutput_pathhas an extension other than.pngor.svg.