api: make transactions autocleanups public
From the code review at https://github.com/ostreedev/ostree/pull/2411#discussion_r690416686:
I think we can push this forward into fully using autocleanups with
_ostree_repo_auto_transaction_start (repo, cancellable, error);?Oh I see, that's private API. Blah. Probably time to make it public.
Side note: I think this one needs to be manually bound in Rust, unless we make it a boxed type.
Regarding this logic, https://github.com/ostreedev/ostree-rs/pull/33/files sketches an alternative/different implementation (which I think I'm liking more than status quo) along the following lines:
- a dedicated internal
reporeference, nullable - explicit commit/abort methods which do consume the guard
- auto-cleanup logic which only triggers an abort call if the guard as not been consumed (via explicit commit/abort) before
I made a pass on this and ported back some of the enhancements from the Rust side, PR at https://github.com/ostreedev/ostree/pull/2454.
I also looked into moving this guard to a gobject boxed type. I admit my shallow knowledge in this area, so please correct me if here below I'm making any wrong statements.
I think that in this specific case OstreeRepoAutoTransaction cannot be expressed as a boxed type due to semantic mismatches. In particular, it is my understanding that a boxed type is primarily meant for type-values that can be (trivially) copied, and thus requires a mandatory non-nullable GBoxedCopyFunc.
In our case instead OstreeRepoAutoTransaction is a guard which enforces scope/ownership, so I think we won't actually expose a way to duplicate an existing guard.
From an out-of-band chat, it would still be preferable to have auto-generated bindings for this.
Going back to a boxed type for this, we can add internal reference counting to OstreeRepoAutoTransaction so that copy/free functions can operate on light references, while still keeping a single guard underneath.