The underlying `ostree_repo_load_file()` API has the caller pass
`NULL` for output arguments it doesn't want. This isn't sanely
bindable in Rust - what the generator does is always request
all values, but maps them all to `Option<T>`.
The main cases are where a user wants either metadata, or both
metadata and content. This API gives just metadata; it's a
bit more efficient as we don't need to open the file, and doesn't
require the caller to `unwrap()`.
Followup to the previous PR. I realized now with `io_lifetimes`
we can offer a safe `dfd_borrow()` that *borrows* the file descriptor
for the repository. (In contrast to the current `.dfd()` that returns
the raw version)
Building on that, add another API that re-acquires a `Dir` instance.
(In the future in theory we could optimize this more by knowing
whether or not the repo was constructed via cap-std, and perhaps
in theory synthesize a `&Dir` reference, but I don't think we
need that now)
I'm trying to make more use of `cap-std` in our stack, and
this will be a key enabling API.
Actually a notable side benefit of this is that we don't need
to teach the ostree C code itself to use `openat2`, we inherit
cap-std's setup.
All of the internal ostree code using the prior `openat()` should
continue to work.
I only did basic sanity checking of this; there may be bugs
in other APIs.
The fact that the uid/gid/mode are big endian bit me when I was
trying to parse this "by hand" in ostree-rs-ext.
Let's add a footgun-free API for this.
(And yeah, we should probably do the same for the other variant types)
The `resolve_rev` C method should really have been
`resolve_rev_optional` from the start - it is more obviously wrong
in Rust because the input parameter `allows_noent` controls
whether the returned `Option` can ever be `None`.
I debated adding this to the C bindings, and may still do so,
but eh it's faster to write + ship in Rust, and the future of ostree is
Rust anyways.
An intimidating spam of compiler errors at the start, but the
biggest was handling the new convention of `ostree_sys::` => `ffi::`.
This will require a semver bump of course.