Bindings for GVariantBuilder
We'll have a way to create and convert to/from Variants after gtk-rs/glib#651 is merged. However, since Variant is supposed to be non-mutable, bindings for GVariantBuilder will be very useful to have.
The requirements of the g_variant_builder_end() API will be a bit annoying to implement.
Maybe could implement most of it on the Rust side to enforce those constraints (possibly even in the type system), and only for actually building (parts of) call into the GLib API.
The requirements of the
g_variant_builder_end()API will be a bit annoying to implement.
How so?
It is not permissible to use builder in any way after this call
That's easy with binding for g_variant_builder_end() take self instead of &mut self, no?
It is an error to call this function in any way that would create an inconsistent value to be constructed
That's a bit tough but either we can duplicate the checks in the C function or we just let the user shoot themselves in the foot (they're using C API after all) and document it?
That's easy with binding for
g_variant_builder_end()takeselfinstead of&mut self, no?
It's refcounted, so that's not enough :)
That's a bit tough but either we can duplicate the checks in the C function or we just let the user shoot themselves in the foot (they're using C API after all) and document it?
Duplicating the checks, yes. Ideally we'd prevent that statically at compile time
Not having the checks is not acceptable though, otherwise it would have to be unsafe functions.
That's easy with binding for
g_variant_builder_end()takeselfinstead of&mut self, no?It's refcounted, so that's not enough :)
But the Rust wrapper struct we'll expose won't be.
That's a bit tough but either we can duplicate the checks in the C function or we just let the user shoot themselves in the foot (they're using C API after all) and document it?
Duplicating the checks, yes. Ideally we'd prevent that statically at compile time
Not having the checks is not acceptable though, otherwise it would have to be unsafe functions.
I guess. :(
But the Rust wrapper struct we'll expose won't be.
That sounds like a good plan