Skip to main content

resolve_chart_format

Function resolve_chart_format 

Source
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 InvalidArgument naming both values so the caller can fix one.
  • Only format set: parse it via ChartFormat::parse.
  • Only output_path set: derive from its extension (.png / .svg). Unknown extensions return InvalidArgument.
  • Neither set: default to PNG (matches the pre-change behavior).

The path is only inspected for its extension — the file need not exist.

§Errors