This is a working proof-of-concept of using NordSecurity/uniffi-bindgen-go to generate Go bindings the same way the Python ones are generated. Running make will generate a demo file that will display embedded C2PA manifests:
I had to bump to uniffi = "0.25.0" to match the expected version for uniffi-bindgen-go. Doing so required this change, which I do not understand in the slightest, but it got it compiling:
I'm not really sure of the best way to get this into the hands of Go developers. Unlike Python, we can't just distribute prebuilt libraries as wheels, so I think inevitably there's going to be a cargo build step somewhere in any projects that make use of this. Not a problem for my use case exactly, but worth contemplating. Maybe it could be as simple as a single cargo install command that you have to run once to get the dependency in place?
I'm making use of the same Stream primitives as the Python library, using a Go implementation of the interface at pkg/c2pa/c2pa.go. I don't really know if this is wise or unwise, but if it's actually useful maybe those primitives could be moved to an upstream library so they wouldn't be duplicated in the Python and Go examples.
I changed crate-type = ["cdylib"] to crate-type = ["staticlib"] which seems like a better fit for Go's single-binary output.
This is a working proof-of-concept of using NordSecurity/uniffi-bindgen-go to generate Go bindings the same way the Python ones are generated. Running
make
will generate a demo file that will display embedded C2PA manifests:Some notes:
uniffi = "0.25.0"
to match the expected version foruniffi-bindgen-go
. Doing so required this change, which I do not understand in the slightest, but it got it compiling:+unsafe impl uniffi::LiftRef for Box {
cargo build
step somewhere in any projects that make use of this. Not a problem for my use case exactly, but worth contemplating. Maybe it could be as simple as a singlecargo install
command that you have to run once to get the dependency in place?Stream
primitives as the Python library, using a Go implementation of the interface atpkg/c2pa/c2pa.go
. I don't really know if this is wise or unwise, but if it's actually useful maybe those primitives could be moved to an upstream library so they wouldn't be duplicated in the Python and Go examples.crate-type = ["cdylib"]
tocrate-type = ["staticlib"]
which seems like a better fit for Go's single-binary output.