[][src]Constant libmpv::mpv_format::Node

pub const Node: u32 = 6; // 6u32

The type is mpv_node.

For reading, you usually would pass a pointer to a stack-allocated mpv_node value to mpv, and when you're done you call mpv_free_node_contents(&node). You're expected not to write to the data - if you have to, copy it first (which you have to do manually).

For writing, you construct your own mpv_node, and pass a pointer to the API. The API will never write to your data (and copy it if needed), so you're free to use any form of allocation or memory management you like.

Warning: when reading, always check the mpv_node.format member. For example, properties might change their type in future versions of mpv, or sometimes even during runtime.

Example for reading:

mpv_node result;
if (mpv_get_property(ctx, "property", MPV_FORMAT_NODE, &result) < 0)
    goto error;
printf("format=%d\n", (int)result.format);
mpv_free_node_contents(&result).

Example for writing:

mpv_node value;
value.format = MPV_FORMAT_STRING;
value.u.string = "hello";
mpv_set_property(ctx, "property", MPV_FORMAT_NODE, &value);