Commit Graph

13 Commits

Author SHA1 Message Date
Colin Walters 887f5b09be repo: Add `query_file` API
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()`.
2022-05-06 12:53:57 -04:00
Colin Walters 19224a411a repo: Add two more cap-std APIs
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)
2022-05-06 12:53:57 -04:00
Colin Walters 6940896c4e Add a `cap-std-apis` feature with open/create
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.
2022-05-06 12:53:57 -04:00
Colin Walters d1731d0ea8 repo: Add an API to read and parse directory metadata
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)
2022-05-06 12:53:57 -04:00
Colin Walters 440d872f68 repo: Add `require_rev` method
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.
2022-05-06 12:53:57 -04:00
Colin Walters 955f0ddb9d repo: Expose dfd_as_file()
The `dfd()` API returns just an integer.  Add a safe API that
makes a copy of the fd.  What we really want here is `BorrowedFd` from
https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md
but that isn't here yet.
2022-05-06 12:53:57 -04:00
Colin Walters deedffde06 Re-export glib, gio
Re-export our dependencies.  See https://gtk-rs.org/blog/2021/06/22/new-release.html
"Dependencies are re-exported".  Users will need e.g. `gio::File`, so this avoids
them needing to update matching versions.

Closes: https://github.com/ostreedev/ostree-rs/issues/12
2022-05-06 12:53:56 -04:00
Colin Walters 8a5ac02822 Update to glib 0.14
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.
2022-05-06 12:53:56 -04:00
Felix Krull 3290d5c2d1 Rewrite handwritten futures functions 2022-05-06 12:53:55 -04:00
Felix Krull bf27ba5dc0 Fix lint in tests 2022-05-06 12:53:55 -04:00
Felix Krull bb4e0c5978 Implement Repo::write_metadata 2022-05-06 12:53:54 -04:00
Felix Krull 78a14d15a3 Implement Repo::write_content 2022-05-06 12:53:54 -04:00
Felix Krull 6776c819f1 tests: reorganise repo tests so they have fewer feature flags 2022-05-06 12:53:54 -04:00