Skip to content

XmpMeta::append_array_item doesn't support creating struct itemsΒ #258

@17cupsofcoffee

Description

@17cupsofcoffee

I've been tinkering with xmp-toolkit-rs to try to parse/update Ableton Live's folder metadata - this has worked pretty well so far, but one part of the schema proved a little awkward to get working through these bindings.

I did find a workaround in the end, but I thought it was worth raising an issue regardless, as it seems like it could be useful feedback for future versions of this library πŸ™‚

For context - Ableton stores each file's metadata as an array of structs, like this:

ablFR:items  (0x200 : isArray)
    [1]  (0x100 : isStruct)
        ablFR:filePath = "Clap Beholder 1.wav"
        ablFR:keywords  (0x200 : isArray)
            [1] = "Creator|Native Instruments"
            [2] = "Drums|Clap"

If I try to use XmpMeta::append_array_item to add a new empty struct to this array, I am forced to add a String value to it (as the method only allows you to pass &XmpValue<String>). But this gives the following error:

XmpError(Bad options parameter, Structs and arrays can't have string values)

In the C++ API, you can pass NULL as the item value, but that functionality isn't exposed through the bindings. It feels like these kinds of functions should possibly take &XmpValue<Option<String>>, or something like that?

The workaround/alternate approach I found was using XmpMeta::array_len and XmpMeta::compose_array_item_path to create a path to the (non-existent) new item. The struct then gets created automatically when I call XmpMeta::compose_struct_field_path to set the fields.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions