macro_rules! __builder_add__ {
    ($builder:expr, None) => { ... };
    ($builder:expr, Bool($val:expr)) => { ... };
    ($builder:expr, Id($val:expr)) => { ... };
    ($builder:expr, Int($val:expr)) => { ... };
    ($builder:expr, Long($val:expr)) => { ... };
    ($builder:expr, Float($val:expr)) => { ... };
    ($builder:expr, Double($val:expr)) => { ... };
    ($builder:expr, String($val:expr)) => { ... };
    ($builder:expr, Bytes($val:expr)) => { ... };
    ($builder:expr, Pointer($type_:expr, $val:expr)) => { ... };
    ($builder:expr, Fd($val:expr)) => { ... };
    ($builder:expr, Rectangle($val:expr)) => { ... };
    ($builder:expr, Fraction($val:expr)) => { ... };
    (
        $builder:expr,
        Struct {
            $( $field_type:tt $field:tt ),* $(,)?
        }
    ) => { ... };
    (
        $builder:expr,
        Object($type_:expr, $id:expr $(,)?) {
            $( $key:expr => $value_type:tt $value:tt ),* $(,)?
        }
    ) => { ... };
}
Expand description

Convenience macro to build a pod from values using a spa pod builder.

For arguments, the macro accepts the builder, and then the structure of the desired pod:

builder_add!(<&mut libspa::pod::builder::Builder>, Bool(<bool>));
builder_add!(<&mut libspa::pod::builder::Builder>, Id(<ibspa::utils::Id>));
builder_add!(<&mut libspa::pod::builder::Builder>, Int(<i32>));
builder_add!(<&mut libspa::pod::builder::Builder>, Long(<i64>));
builder_add!(<&mut libspa::pod::builder::Builder>, Float(<f32>));
builder_add!(<&mut libspa::pod::builder::Builder>, Double(<f64>));
builder_add!(<&mut libspa::pod::builder::Builder>, Bytes(<&[u8]>));
// Macro using `Pointer` can only be called in `unsafe` block.
// Safety rules from `Builder::add_pointer()` apply.
builder_add!(<&mut libspa::pod::builder::Builder>, Pointer(<*const c_void>));
builder_add!(<&mut libspa::pod::builder::Builder>, Fd(<i64>));
builder_add!(<&mut libspa::pod::builder::Builder>, Rectangle(<libspa::utils::Rectangle>));
builder_add!(<&mut libspa::pod::builder::Builder>, Fraction(<libspa::utils::Fraction>));
builder_add!(<&mut libspa::pod::builder::Builder>,
    Struct {
        // 0 to n fields, e.g.:
        Struct {
            Int(<i32>),
            Float(<f32>),
        },
        Bytes(<&[u8]>),
    }
);
builder_add!(<&mut libspa::pod::builder::Builder>,
    Object(
        <type as u32>,
        <id as u32>
    ) {
        // 0 to n properties of format
        // `<key as u32> => <value>`
        // e.g.
          0 => Bool(false),
        313 => String("313"),
    }
);

§Returns

The macro returns a Result<(), Errno>. If building succeeds, an Ok(()) is returned. Otherwise, the Err(Errno) from the point where building failed is returned, and the rest of the values are not added.