Skip to content

Allow naming formats registered via hooks #2616

@Shnatsel

Description

@Shnatsel

PR #2372 added decoding hooks, so a third-party format implementation can be registered as a plugin and work through all the usual facilities in an abstract way.

It also added a Format enum that lets image refer to these plugin formats:

#[derive(Clone)]
enum Format {
BuiltIn(ImageFormat),
Extension(OsString),
}

However, that enum is private.

In wondermagick I keep running into the need to name formats, including plugin formats. For example, the input can be prefixed with a format modifier, e.g. webp:some_file, that specifies what format "some_file" should be treated as. There's Decoder::set_format that allows precisely that, but it accepts ImageFormat enum that can only represents built-in formats, not the ones registered via plugins.

Draft

I think the best way is going to be to just another variant to ImageFormat to represent third-party plugins, in the same way as the private Format does today, and retire the private Format afterwards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions