Merge pull request #2575 from cgwalters/merge-ostree-rs

Merge ostree-rs into this repository
This commit is contained in:
Colin Walters 2022-05-09 16:41:08 -04:00 committed by GitHub
commit 891c7dffa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
92 changed files with 195282 additions and 18 deletions

View File

@ -1,31 +1,68 @@
---
name: Rust
permissions:
actions: read
on:
push:
branches: [main]
branches: [ main ]
pull_request:
branches: [main]
permissions:
contents: read
branches: [ main ]
env:
CARGO_TERM_COLOR: always
ACTIONS_LINTS_TOOLCHAIN: 1.53.0
CARGO_PROJECT_FEATURES: "v2021_3"
# Minimum supported Rust version (MSRV)
ACTION_MSRV_TOOLCHAIN: 1.54.0
# Pinned toolchain for linting
ACTION_LINTS_TOOLCHAIN: 1.56.0
jobs:
linting:
name: "Lints, pinned toolchain"
build:
runs-on: ubuntu-latest
container: quay.io/coreos-assembler/fcos-buildroot:testing-devel
steps:
- uses: actions/checkout@v2
- name: Cache Dependencies
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
- name: Build
run: cargo build --verbose --features=${{ env['CARGO_PROJECT_FEATURES'] }}
- name: Run tests
run: cargo test --verbose --features=${{ env['CARGO_PROJECT_FEATURES'] }}
build-minimum-toolchain:
name: "Build, minimum supported toolchain (MSRV)"
runs-on: ubuntu-latest
container: quay.io/coreos-assembler/fcos-buildroot:testing-devel
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Remove system Rust toolchain
run: dnf remove -y rust cargo
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env['ACTIONS_LINTS_TOOLCHAIN'] }}
toolchain: ${{ env['ACTION_MSRV_TOOLCHAIN'] }}
default: true
- name: Cache Dependencies
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
- name: cargo build
run: cargo build --features=${{ env['CARGO_PROJECT_FEATURES'] }}
linting:
name: "Lints, pinned toolchain"
runs-on: ubuntu-latest
container: quay.io/coreos-assembler/fcos-buildroot:testing-devel
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Remove system Rust toolchain
run: dnf remove -y rust cargo
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env['ACTION_LINTS_TOOLCHAIN'] }}
default: true
components: rustfmt, clippy
- name: cargo fmt (check)
run: cargo fmt -- --check -l
run: cargo fmt -p ostree -- --check -l
- name: cargo clippy (warnings)
run: cargo clippy -p ostree --features=${{ env['CARGO_PROJECT_FEATURES'] }} -- -D warnings

View File

@ -1,6 +1,94 @@
# Today, this repository only uses Rust for tests. This
# toplevel Cargo.toml helps tools like rust-analyzer understand
# that this project contains Rust code. We don't otherwise currently
# use `cargo` for any part of the core build.
[package]
authors = ["Felix Krull"]
description = "Rust bindings for libostree"
documentation = "https://docs.rs/ostree"
edition = "2018"
keywords = ["ostree", "libostree"]
license = "MIT"
name = "ostree"
readme = "README.md"
repository = "https://github.com/ostreedev/ostree-rs"
version = "0.13.6"
exclude = [
"rust-bindings/conf/**",
"rust-bindings/gir-files/**",
"rust-bindings/sys/**",
".gitlab-ci.yml",
"LICENSE.LGPL*",
]
[package.metadata.docs.rs]
features = ["dox"]
[lib]
name = "ostree"
path = "rust-bindings/src/lib.rs"
[workspace]
members = ["tests/inst"]
members = [".", "rust-bindings/sys"]
[dependencies]
bitflags = "1.2.1"
cap-std = { version = "0.24", optional = true}
io-lifetimes = { version = "0.5", optional = true}
ffi = { package = "ostree-sys", path = "rust-bindings/sys", version = "0.9.1" }
gio = "0.14"
glib = "0.14.4"
hex = "0.4.2"
libc = "0.2"
once_cell = "1.4.0"
radix64 = "0.6.2"
thiserror = "1.0.20"
[dev-dependencies]
maplit = "1.0.2"
openat = "0.1.19"
tempfile = "3"
cap-tempfile = "0.24"
[features]
cap-std-apis = ["cap-std", "io-lifetimes", "v2017_10"]
dox = ["ffi/dox"]
v2014_9 = ["ffi/v2014_9"]
v2015_7 = ["v2014_9", "ffi/v2015_7"]
v2016_3 = ["v2015_7", "ffi/v2016_3"]
v2016_4 = ["v2016_3", "ffi/v2016_4"]
v2016_5 = ["v2016_4", "ffi/v2016_5"]
v2016_6 = ["v2016_5", "ffi/v2016_6"]
v2016_7 = ["v2016_6", "ffi/v2016_7"]
v2016_8 = ["v2016_7", "ffi/v2016_8"]
v2016_14 = ["v2016_8", "ffi/v2016_14"]
v2017_1 = ["v2016_14", "ffi/v2017_1"]
v2017_2 = ["v2017_1", "ffi/v2017_2"]
v2017_3 = ["v2017_2", "ffi/v2017_3"]
v2017_4 = ["v2017_3", "ffi/v2017_4"]
v2017_6 = ["v2017_4", "ffi/v2017_6"]
v2017_7 = ["v2017_6", "ffi/v2017_7"]
v2017_8 = ["v2017_7", "ffi/v2017_8"]
v2017_9 = ["v2017_8", "ffi/v2017_9"]
v2017_10 = ["v2017_9", "ffi/v2017_10"]
v2017_11 = ["v2017_10", "ffi/v2017_11"]
v2017_12 = ["v2017_11", "ffi/v2017_12"]
v2017_13 = ["v2017_12", "ffi/v2017_13"]
v2017_15 = ["v2017_13", "ffi/v2017_15"]
v2018_2 = ["v2017_15", "ffi/v2018_2"]
v2018_3 = ["v2018_2", "ffi/v2018_3"]
v2018_5 = ["v2018_3", "ffi/v2018_5"]
v2018_6 = ["v2018_5", "ffi/v2018_6"]
v2018_7 = ["v2018_6", "ffi/v2018_7"]
v2018_9 = ["v2018_7", "ffi/v2018_9"]
v2019_2 = ["v2018_9", "ffi/v2019_2"]
v2019_3 = ["v2019_2", "ffi/v2019_3"]
v2019_4 = ["v2019_3", "ffi/v2019_4"]
v2019_6 = ["v2019_4", "ffi/v2019_6"]
v2020_1 = ["v2019_6", "ffi/v2020_1"]
v2020_2 = ["v2020_1", "ffi/v2020_2"]
v2020_4 = ["v2020_2", "ffi/v2020_4"]
v2020_7 = ["v2020_4", "ffi/v2020_7"]
v2020_8 = ["v2020_7", "ffi/v2020_8"]
v2021_1 = ["v2020_8", "ffi/v2021_1"]
v2021_2 = ["v2021_1", "ffi/v2021_2"]
v2021_3 = ["v2021_2", "ffi/v2021_3"]
v2021_4 = ["v2021_3", "ffi/v2021_4"]
v2021_5 = ["v2021_4", "ffi/v2021_5"]

2
cfg.mk
View File

@ -1,4 +1,4 @@
export VC_LIST_EXCEPT_DEFAULT=^(docs/.*|git.mk|lib/.*|m4/.*|md5/.*|build-aux/.*|src/gettext\.h|.*ChangeLog|buildutil/.*)$$
export VC_LIST_EXCEPT_DEFAULT=^(rust-bindings/.*|docs/.*|git.mk|lib/.*|m4/.*|md5/.*|build-aux/.*|src/gettext\.h|.*ChangeLog|buildutil/.*)$$
local-checks-to-skip = \
sc_const_long_option \

View File

@ -0,0 +1,28 @@
#!/bin/sh
set -eu
get_features() {
cargo read-manifest \
| jq -jr '.features
| keys
| map(select(. != "dox"))
| map(. + " ")
| .[]'
}
cat <<EOF
include: /.ci/gitlab-ci-base.yml
EOF
features=$(get_features)
for feature in $features; do
cat <<EOF
test_feature_${feature}:
extends: .fedora-ostree-devel
script:
- cargo test --verbose --workspace --features ${feature}
EOF
done

View File

@ -0,0 +1,31 @@
.sccache:
variables:
SCCACHE_URL: https://github.com/mozilla/sccache/releases/download/0.2.13/sccache-0.2.13-x86_64-unknown-linux-musl.tar.gz
CARGO_TARGET_DIR: ${CI_PROJECT_DIR}/target
CARGO_HOME: ${CI_PROJECT_DIR}/cargo
SCCACHE_DIR: ${CI_PROJECT_DIR}/sccache
RUSTC_WRAPPER: sccache
cache:
paths:
- cargo/
- sccache/
# config with sccache based on Fedora Rawhide, i.e. very recent libostree
.fedora-ostree-devel:
image: registry.fedoraproject.org/fedora:rawhide
extends: .sccache
before_script:
- dnf install -y cargo rust ostree-devel
- curl -L "${SCCACHE_URL}" | tar -C /usr/bin/ -xz --wildcards --strip-components=1 '*/sccache'
# ??? This seems to not work correctly on Fedora Rawhide right now?
- ln -s /usr/bin/x86_64-redhat-linux-gnu-pkg-config /usr/bin/x86_64-redhat-linux-pkg-config
# config with sccache based on Rust image, i.e. older libostree but shorter setup and rustup access
.rust-ostree-devel:
image: rust
extends: .sccache
before_script:
- apt-get update
- apt-get install -y libostree-dev
- curl -L "${SCCACHE_URL}" | tar -C /usr/bin/ -xz --wildcards --strip-components=1 '*/sccache'

7
rust-bindings/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
.idea
target
cargo
sccache
**/*.rs.bk
Cargo.lock
.vagrant

21
rust-bindings/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018, 2019, 2020 Felix Krull
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

481
rust-bindings/LICENSE.LGPL2 Normal file
View File

@ -0,0 +1,481 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -0,0 +1,502 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

65
rust-bindings/Makefile Normal file
View File

@ -0,0 +1,65 @@
GIR_REPO := https://github.com/gtk-rs/gir.git
GIR_VERSION := e8f82cf63f2b2fba7af9440248510c4b7e5ab787
OSTREE_REPO := ../ostree
OSTREE_VERSION := patch-v2022.2
RUSTDOC_STRIPPER_VERSION := 0.1.17
all: gir
.PHONY: gir gir-report update-gir-files remove-gir-files merge-lgpl-docs ci-build-stages
# -- gir generation --
target/tools/bin/gir:
cargo install --root target/tools --git $(GIR_REPO) --rev $(GIR_VERSION) -- gir
gir: target/tools/bin/gir
target/tools/bin/gir -c conf/ostree-sys.toml
target/tools/bin/gir -c conf/ostree.toml
gir-report: target/tools/bin/gir
target/tools/bin/gir -c conf/ostree.toml -m not_bound
# -- LGPL docs generation --
target/tools/bin/rustdoc-stripper:
cargo install --root target/tools --version $(RUSTDOC_STRIPPER_VERSION) -- rustdoc-stripper
merge-lgpl-docs: target/tools/bin/gir target/tools/bin/rustdoc-stripper
target/tools/bin/gir -c conf/ostree.toml -m doc
target/tools/bin/rustdoc-stripper -g -o target/vendor.md
# -- gir file management --
update-gir-files: \
remove-gir-files \
gir-files \
gir-files/GLib-2.0.gir \
gir-files/Gio-2.0.gir \
gir-files/GObject-2.0.gir \
gir-files/OSTree-1.0.gir
remove-gir-files:
rm -f gir-files/*.gir
gir-files:
mkdir -p gir-files
%.gir:
curl -o $@ -L https://github.com/gtk-rs/gir-files/raw/master/${@F}
gir-files/OSTree-1.0.gir:
podman build \
--pull \
--build-arg OSTREE_REPO=$(OSTREE_REPO) \
--build-arg OSTREE_VERSION=$(OSTREE_VERSION) \
-t ostree-build \
.
podman create \
--name ostree-gir-container \
ostree-build
podman cp \
ostree-gir-container:/build/OSTree-1.0.gir \
gir-files/OSTree-1.0.gir
podman rm \
ostree-gir-container

133
rust-bindings/README.md Normal file
View File

@ -0,0 +1,133 @@
# ostree-rs
[![pipeline status](https://gitlab.com/fkrull/ostree-rs/badges/main/pipeline.svg)](https://gitlab.com/fkrull/ostree-rs/commits/main)
[![Crates.io](https://img.shields.io/crates/v/ostree.svg)](https://crates.io/crates/ostree)
[![main-docs](https://img.shields.io/badge/docs-main-brightgreen.svg)](https://fkrull.gitlab.io/ostree-rs/ostree)
**Rust** bindings for [libostree](https://ostree.readthedocs.io).
libostree is both a shared library and suite of command line tools that combines
a "git-like" model for committing and downloading bootable filesystem trees,
along with a layer for deploying them and managing the bootloader configuration.
> **Note**: this crate was renamed from the `libostree` crate.
## Status
Most bindings that can be auto-generated are being auto-generated by now.
Anything that is not yet supported by the crate probably requires handwritten
bindings. These will most likely be added on an as-needed basis.
## Using
### Requirements
The `ostree` crate requires libostree and the libostree development headers.
On Debian and Ubuntu:
```ShellSession
$ sudo apt-get install libostree-1 libostree-dev
```
On Fedora and CentOS:
```ShellSession
$ sudo dnf install ostree-libs ostree-devel
```
### Installing
To use the crate, add it to your `Cargo.toml`:
```toml
[dependencies]
ostree = "0.10"
```
To use features from later libostree versions, you need to specify the release
version as well:
```toml
[dependencies.ostree]
version = "0.10"
features = ["v2021_1"]
```
## Developing
The `ostree` and `ostree-sys` crates can be built and tested using regular
Cargo commands.
### Generated code
Most code is generated based on the gir files using the
[gir](https://github.com/gtk-rs/gir) tool.
You can update `OSTree-1.0.gir` by directly copying it from a local ostree build.
Or, these parts can be regenerated using
the included Makefile:
```ShellSession
$ make gir
```
Run the following command to update the bundled gir files:
```ShellSession
$ make update-gir-files
```
### Documentation
The libostree API documentation is not included in the code by default because
of its LGPL license. This means normal `cargo doc` runs don't include API docs
for the generated code. Run the `merge-lgpl-docs` Makefile target to include
the API docs in the source so they can be consumed by `cargo doc`:
```ShellSession
$ make merge-lgpl-docs
```
Keep in mind that if you build the crate with the API docs included, it's
effectively LGPL-licensed and you need to comply with the LGPL requirements
(specifically, allowing users of your end product to swap out the LGPL'd
parts).
CI includes the LGPL docs in the documentation build.
### Updating glib-rs
* update `GIR_VERSION` in `Makefile` to the latest gir commit (matching the target glib-rs version)
* `make gir` to regenerate the generated code
* inspect differences in generated code
* update glib-rs dependencies in `Cargo.toml` and `sys/Cargo.toml`
### Updating ostree
* update `OSTREE_VERSION` in `Makefile`
* `make update-gir-files` to update all gir files
* inspect differences in `OSTree-1.0.gir`
* `make gir` to regenerate the generated code
* add any new feature levels to `Cargo.toml`
* update the example feature level in `README.md` in case of a new feature level
### Releases
Releases can be done using the publish_* jobs in the pipeline. There's no
versioning helper so version bumps need to be done manually.
The version needs to be changed in the following places (if applicable):
* in `sys/Cargo.toml` for the -sys crate version
* in the `ostree-sys =` dependency in `Cargo.toml`
* in `Cargo.toml` for the main crate version
* in `README.md` in the *Installing* section in case of major version bumps
Then tag the commit as `ostree/x.y.z` and/or `ostree-sys/x.y.z`. This will run
the crates.io deployment jobs. Main and -sys crate don't have to be released in
lockstep.
## License
The `ostree` crate is licensed under the MIT license. See the LICENSE file for
details.
libostree itself is licensed under the LGPL2+. See its
[licensing information](https://ostree.readthedocs.io#licensing) for more
information.
The libostree GIR file (`gir-files/OSTree-1.0.gir`) is derived from the
libostree source code and is also licensed under the LGPL2+. A copy of the
LGPL version 2 is included in the LICENSE.LGPL2 file.
The remaining GIR files (`gir-files/*.gir`) are from the glib project and
are licensed under the LGPL2.1+. A copy of the LGPL version 2.1 is included
in the LICENSE.LGPL2.1 file.

View File

@ -0,0 +1,39 @@
[options]
work_mode = "sys"
library = "OSTree"
version = "1.0"
target_path = "../sys"
single_version_file = true
external_libraries = [
"GLib",
"GObject",
"Gio",
]
ignore = [
# private API (not in installed headers)
"OSTree.BootloaderInterface",
"OSTree.ChecksumInputStream",
"OSTree.ChecksumInputStreamClass",
"OSTree.CmdPrivateVTable",
"OSTree.LibarchiveInputStream",
"OSTree.LibarchiveInputStreamClass",
"OSTree.LzmaCompressorClass",
"OSTree.LzmaDecompressorClass",
"OSTree.RepoFileEnumeratorClass",
"OSTree.RollsumMatches",
"OSTree.SignDummy",
"OSTree.SignDummyClass",
"OSTree.SignEd25519",
"OSTree.SignEd25519Class",
# version-dependent constants
"OSTree.RELEASE_VERSION",
"OSTree.VERSION",
"OSTree.VERSION_S",
"OSTree.YEAR_VERSION",
# build-dependent constants
"OSTree.BUILT_FEATURES",
]
girs_directories = [ "../gir-files" ]

View File

@ -0,0 +1,266 @@
# Legend:
# - [IGNORE] we don't want to autogenerate this
# - [MANUAL] we have manual wrappers for this, but would prefer to autogenerate it
# - [FAIL] this is currently disabled because it generates broken code
[options]
work_mode = "normal"
library = "OSTree"
version = "1.0"
target_path = ".."
doc_target_path = "../target/vendor.md"
deprecate_by_min_version = true
single_version_file = true
generate_display_trait = true
girs_directories = [ "../gir-files" ]
generate = [
"OSTree.AsyncProgress",
"OSTree.BootconfigParser",
"OSTree.ChecksumFlags",
"OSTree.ContentWriter",
"OSTree.CommitSizesEntry",
"OSTree.Deployment",
"OSTree.DeploymentUnlockedState",
"OSTree.DiffFlags",
"OSTree.DiffItem",
"OSTree.GpgSignatureAttr",
"OSTree.GpgSignatureFormatFlags",
"OSTree.GpgVerifyResult",
"OSTree.MutableTree",
"OSTree.ObjectType",
"OSTree.Remote",
"OSTree.RepoCheckoutFilterResult",
"OSTree.RepoCheckoutMode",
"OSTree.RepoCheckoutOverwriteMode",
"OSTree.RepoCommitFilterResult",
"OSTree.RepoCommitFilter",
"OSTree.RepoCommitIterResult",
"OSTree.RepoCommitModifierFlags",
"OSTree.RepoCommitTraverseFlags",
"OSTree.RepoCommitModifier",
"OSTree.RepoCommitState",
"OSTree.RepoDevInoCache",
"OSTree.RepoFile",
"OSTree.RepoFinderAvahi",
"OSTree.RepoFinderConfig",
"OSTree.RepoFinderMount",
"OSTree.RepoFinderOverride",
"OSTree.RepoListObjectsFlags",
"OSTree.RepoListRefsExtFlags",
"OSTree.RepoMode",
"OSTree.RepoPruneFlags",
"OSTree.RepoPullFlags",
"OSTree.RepoRemoteChange",
"OSTree.RepoResolveRevExtFlags",
"OSTree.RepoVerifyFlags",
"OSTree.SePolicyRestoreconFlags",
"OSTree.StaticDeltaGenerateOpt",
"OSTree.SysrootSimpleWriteDeploymentFlags",
"OSTree.SysrootUpgrader",
"OSTree.SysrootUpgraderFlags",
"OSTree.SysrootUpgraderPullFlags",
]
manual = [
# types from glib/gio we need
"Gio.AsyncReadyCallback",
"Gio.AsyncResult",
"Gio.Cancellable",
"Gio.File",
"Gio.FileInfo",
"Gio.FileQueryInfoFlags",
"Gio.FilterInputStream",
"Gio.InputStream",
"Gio.OutputStream",
"Gio.VolumeMonitor",
"GLib.Bytes",
"GLib.Checksum",
"GLib.DestroyNotify",
"GLib.Error",
"GLib.KeyFile",
"GLib.MainContext",
"GLib.Quark",
"GLib.String",
"GLib.Variant",
"GLib.VariantType",
# [MANUAL] types implemented by hand
"OSTree.KernelArgs",
"OSTree.RepoCheckoutAtOptions",
"OSTree.RepoCheckoutFilter",
"OSTree.RepoTransactionStats",
"OSTree.SysrootWriteDeploymentsOpts",
"OSTree.SysrootDeployTreeOpts",
]
ignore = [
# only used for the already-deprecated checkout_tree_at function
"OSTree.RepoCheckoutOptions",
# types for zero-terminated arrays we probably don't want
"OSTree.CollectionRefv",
"OSTree.RepoFinderResultv",
# not part of the public interface, as far as I can tell
"OSTree.Bootloader",
"OSTree.BootloaderGrub2",
"OSTree.BootloaderInterface",
"OSTree.BootloaderSyslinux",
"OSTree.BootloaderUboot",
"OSTree.BootloaderZipl",
"OSTree.ChecksumInputStream",
"OSTree.ChecksumInputStreamBuilder",
"OSTree.CmdPrivateVTable",
"OSTree.GpgVerifier",
"OSTree.LibarchiveInputStream",
"OSTree.LzmaCompressor",
"OSTree.LzmaDecompressor",
"OSTree.RollsumMatches",
# builders we don't want
"OSTree.RepoBuilder",
"OSTree.RepoFinderMountBuilder",
"OSTree.SePolicyBuilder",
"OSTree.SysrootBuilder",
"OSTree.SysrootUpgraderBuilder",
]
[crate_name_overrides]
os_tree = "ostree"
[[object]]
name = "OSTree.CollectionRef"
status = "generate"
[[object.function]]
# [IGNORE] helper functions for NULL-terminated arrays
pattern = "^(dupv|freev)$"
ignore = true
[[object.function]]
# [IGNORE] clone() should already be this
name = "dup"
ignore = true
[[object]]
name = "OSTree.Repo"
status = "generate"
concurrency = "send"
[[object.function]]
# [MANUAL] we special-case the checksum value
pattern = "^(write_content|write_content_async|write_metadata|write_metadata_async)$"
ignore = true
[[object.function]]
# [FAIL] these fail because of issues with arrays of dubious lifetimes
pattern = "^(find_remotes_async|pull_from_remotes_async)$"
ignore = true
[[object.function]]
# [IGNORE] this is deprecated and supposedly unsafe for GI
name = "checkout_tree_at"
ignore = true
[[object.function]]
name = "checkout_at"
[[object.function.parameter]]
name = "options"
const = true
[[object.function.parameter]]
name = "destination_path"
string_type = "filename"
[[object]]
name = "OSTree.RepoFinder"
status = "generate"
[[object.function]]
# [FAIL] these fail because of issues with arrays of dubious lifetimes/NULL-terminated arrays
pattern = "^(resolve_async|resolve_all_async)$"
ignore = true
[[object]]
name = "OSTree.RepoFinderResult"
status = "generate"
[[object.function]]
# [IGNORE] array helper function
name = "freev"
ignore = true
[[object.function]]
# [IGNORE] clone() should already be this
name = "dup"
ignore = true
[[object]]
name = "OSTree.SePolicy"
status = "generate"
concurrency = "send"
[[object.function]]
# [IGNORE] has an unused raw pointer parameter
name = "fscreatecon_cleanup"
ignore = true
[[object]]
name = "OSTree.Sign"
status = "generate"
[[object.function]]
# [IGNORE] these shouldn't be on this type, they belong to subclasses
pattern = "^(dummy_.+|ed25519_.+)$"
ignore = true
[[object]]
name = "OSTree.Sysroot"
status = "generate"
[[object.function]]
name = "deploy_tree_with_options"
[[object.function.parameter]]
name = "opts"
const = true
[[object.function]]
name = "stage_tree_with_options"
[[object.function.parameter]]
name = "opts"
const = true
[[object.function]]
name = "write_deployments_with_options"
[[object.function.parameter]]
name = "opts"
const = true
[[object.function]]
# [IGNORE] overlaps with repo()
name = "get_repo"
ignore = true
[[object]]
name = "OSTree.*"
status = "generate"
[[object.function]]
# [MANUAL] probably can't be autogenerated because of the custom Checksum type
pattern = "^(checksum_file|checksum_file_async|checksum_file_at|checksum_file_from_input)$"
ignore = true
[[object.function]]
# [IGNORE] low-level checksum functions, we have a custom checksum API
pattern = "^(cmp_checksum_bytes|checksum_from_bytes|checksum_to_bytes|checksum_inplace_from_bytes|checksum_inplace_to_bytes|checksum_b64_from_bytes|checksum_b64_to_bytes|checksum_b64_inplace_from_bytes|checksum_b64_inplace_to_bytes)$"
ignore = true
[[object.function]]
# [IGNORE] needs custom handling to deal with its raw pointer parameter
name = "hash_object_name"
ignore = true
[[object.function]]
# [IGNORE] private API
name = "cmd__private__"
ignore = true
[[object.constant]]
# [IGNORE] version-dependent constants
pattern = "^(VERSION|VERSION_S|YEAR_VERSION|RELEASE_VERSION)$"
ignore = true
[[object.constant]]
# [IGNORE] build-dependent constants
name = "BUILT_FEATURES"
ignore = true

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1
rust-bindings/src/.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
auto/** linguist-generated=true

157
rust-bindings/src/auto/async_progress.rs generated Normal file
View File

@ -0,0 +1,157 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::object::ObjectType as ObjectType_;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
glib::wrapper! {
#[doc(alias = "OstreeAsyncProgress")]
pub struct AsyncProgress(Object<ffi::OstreeAsyncProgress, ffi::OstreeAsyncProgressClass>);
match fn {
type_ => || ffi::ostree_async_progress_get_type(),
}
}
impl AsyncProgress {
#[doc(alias = "ostree_async_progress_new")]
pub fn new() -> AsyncProgress {
unsafe {
from_glib_full(ffi::ostree_async_progress_new())
}
}
//#[doc(alias = "ostree_async_progress_new_and_connect")]
//pub fn new_and_connect(changed: /*Unimplemented*/Option<Fundamental: Pointer>, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> AsyncProgress {
// unsafe { TODO: call ffi:ostree_async_progress_new_and_connect() }
//}
#[cfg(any(feature = "v2019_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2019_6")))]
#[doc(alias = "ostree_async_progress_copy_state")]
pub fn copy_state(&self, dest: &AsyncProgress) {
unsafe {
ffi::ostree_async_progress_copy_state(self.to_glib_none().0, dest.to_glib_none().0);
}
}
#[doc(alias = "ostree_async_progress_finish")]
pub fn finish(&self) {
unsafe {
ffi::ostree_async_progress_finish(self.to_glib_none().0);
}
}
//#[cfg(any(feature = "v2017_6", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_6")))]
//#[doc(alias = "ostree_async_progress_get")]
//pub fn get(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
// unsafe { TODO: call ffi:ostree_async_progress_get() }
//}
#[cfg(any(feature = "v2017_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_6")))]
#[doc(alias = "ostree_async_progress_get_status")]
#[doc(alias = "get_status")]
pub fn status(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_async_progress_get_status(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_async_progress_get_uint")]
#[doc(alias = "get_uint")]
pub fn uint(&self, key: &str) -> u32 {
unsafe {
ffi::ostree_async_progress_get_uint(self.to_glib_none().0, key.to_glib_none().0)
}
}
#[doc(alias = "ostree_async_progress_get_uint64")]
#[doc(alias = "get_uint64")]
pub fn uint64(&self, key: &str) -> u64 {
unsafe {
ffi::ostree_async_progress_get_uint64(self.to_glib_none().0, key.to_glib_none().0)
}
}
#[cfg(any(feature = "v2017_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_6")))]
#[doc(alias = "ostree_async_progress_get_variant")]
#[doc(alias = "get_variant")]
pub fn variant(&self, key: &str) -> Option<glib::Variant> {
unsafe {
from_glib_full(ffi::ostree_async_progress_get_variant(self.to_glib_none().0, key.to_glib_none().0))
}
}
//#[cfg(any(feature = "v2017_6", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_6")))]
//#[doc(alias = "ostree_async_progress_set")]
//pub fn set(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
// unsafe { TODO: call ffi:ostree_async_progress_set() }
//}
#[cfg(any(feature = "v2017_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_6")))]
#[doc(alias = "ostree_async_progress_set_status")]
pub fn set_status(&self, status: Option<&str>) {
unsafe {
ffi::ostree_async_progress_set_status(self.to_glib_none().0, status.to_glib_none().0);
}
}
#[doc(alias = "ostree_async_progress_set_uint")]
pub fn set_uint(&self, key: &str, value: u32) {
unsafe {
ffi::ostree_async_progress_set_uint(self.to_glib_none().0, key.to_glib_none().0, value);
}
}
#[doc(alias = "ostree_async_progress_set_uint64")]
pub fn set_uint64(&self, key: &str, value: u64) {
unsafe {
ffi::ostree_async_progress_set_uint64(self.to_glib_none().0, key.to_glib_none().0, value);
}
}
#[cfg(any(feature = "v2017_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_6")))]
#[doc(alias = "ostree_async_progress_set_variant")]
pub fn set_variant(&self, key: &str, value: &glib::Variant) {
unsafe {
ffi::ostree_async_progress_set_variant(self.to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0);
}
}
#[doc(alias = "changed")]
pub fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn changed_trampoline<F: Fn(&AsyncProgress) + 'static>(this: *mut ffi::OstreeAsyncProgress, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(changed_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
}
impl Default for AsyncProgress {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for AsyncProgress {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("AsyncProgress")
}
}

View File

@ -0,0 +1,114 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeBootconfigParser")]
pub struct BootconfigParser(Object<ffi::OstreeBootconfigParser>);
match fn {
type_ => || ffi::ostree_bootconfig_parser_get_type(),
}
}
impl BootconfigParser {
#[doc(alias = "ostree_bootconfig_parser_new")]
pub fn new() -> BootconfigParser {
unsafe {
from_glib_full(ffi::ostree_bootconfig_parser_new())
}
}
#[doc(alias = "ostree_bootconfig_parser_clone")]
pub fn clone(&self) -> Option<BootconfigParser> {
unsafe {
from_glib_full(ffi::ostree_bootconfig_parser_clone(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_bootconfig_parser_get")]
pub fn get(&self, key: &str) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_bootconfig_parser_get(self.to_glib_none().0, key.to_glib_none().0))
}
}
#[cfg(any(feature = "v2020_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_7")))]
#[doc(alias = "ostree_bootconfig_parser_get_overlay_initrds")]
#[doc(alias = "get_overlay_initrds")]
pub fn overlay_initrds(&self) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::ostree_bootconfig_parser_get_overlay_initrds(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_bootconfig_parser_parse")]
pub fn parse<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(&self, path: &P, cancellable: Option<&Q>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_bootconfig_parser_parse(self.to_glib_none().0, path.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_bootconfig_parser_parse_at")]
pub fn parse_at<P: IsA<gio::Cancellable>>(&self, dfd: i32, path: &str, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_bootconfig_parser_parse_at(self.to_glib_none().0, dfd, path.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_bootconfig_parser_set")]
pub fn set(&self, key: &str, value: &str) {
unsafe {
ffi::ostree_bootconfig_parser_set(self.to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0);
}
}
#[cfg(any(feature = "v2020_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_7")))]
#[doc(alias = "ostree_bootconfig_parser_set_overlay_initrds")]
pub fn set_overlay_initrds(&self, initrds: &[&str]) {
unsafe {
ffi::ostree_bootconfig_parser_set_overlay_initrds(self.to_glib_none().0, initrds.to_glib_none().0);
}
}
#[doc(alias = "ostree_bootconfig_parser_write")]
pub fn write<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(&self, output: &P, cancellable: Option<&Q>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_bootconfig_parser_write(self.to_glib_none().0, output.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_bootconfig_parser_write_at")]
pub fn write_at<P: IsA<gio::Cancellable>>(&self, dfd: i32, path: &str, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_bootconfig_parser_write_at(self.to_glib_none().0, dfd, path.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
}
impl Default for BootconfigParser {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for BootconfigParser {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("BootconfigParser")
}
}

56
rust-bindings/src/auto/collection_ref.rs generated Normal file
View File

@ -0,0 +1,56 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::translate::*;
use std::hash;
glib::wrapper! {
#[derive(Debug, PartialOrd, Ord)]
pub struct CollectionRef(Boxed<ffi::OstreeCollectionRef>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::ostree_collection_ref_get_type(), ptr as *mut _) as *mut ffi::OstreeCollectionRef,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::ostree_collection_ref_get_type(), ptr as *mut _),
type_ => || ffi::ostree_collection_ref_get_type(),
}
}
impl CollectionRef {
#[doc(alias = "ostree_collection_ref_new")]
pub fn new(collection_id: Option<&str>, ref_name: &str) -> Option<CollectionRef> {
unsafe {
from_glib_full(ffi::ostree_collection_ref_new(collection_id.to_glib_none().0, ref_name.to_glib_none().0))
}
}
#[doc(alias = "ostree_collection_ref_equal")]
fn equal(&self, ref2: &CollectionRef) -> bool {
unsafe {
from_glib(ffi::ostree_collection_ref_equal(ToGlibPtr::<*const ffi::OstreeCollectionRef>::to_glib_none(self).0 as glib::ffi::gconstpointer, ToGlibPtr::<*const ffi::OstreeCollectionRef>::to_glib_none(ref2).0 as glib::ffi::gconstpointer))
}
}
#[doc(alias = "ostree_collection_ref_hash")]
fn hash(&self) -> u32 {
unsafe {
ffi::ostree_collection_ref_hash(ToGlibPtr::<*const ffi::OstreeCollectionRef>::to_glib_none(self).0 as glib::ffi::gconstpointer)
}
}
}
impl PartialEq for CollectionRef {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.equal(other)
}
}
impl Eq for CollectionRef {}
impl hash::Hash for CollectionRef {
#[inline]
fn hash<H>(&self, state: &mut H) where H: hash::Hasher {
hash::Hash::hash(&self.hash(), state)
}
}

View File

@ -0,0 +1,26 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::ObjectType;
use glib::translate::*;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct CommitSizesEntry(Boxed<ffi::OstreeCommitSizesEntry>);
match fn {
copy => |ptr| ffi::ostree_commit_sizes_entry_copy(ptr),
free => |ptr| ffi::ostree_commit_sizes_entry_free(ptr),
type_ => || ffi::ostree_commit_sizes_entry_get_type(),
}
}
impl CommitSizesEntry {
#[doc(alias = "ostree_commit_sizes_entry_new")]
pub fn new(checksum: &str, objtype: ObjectType, unpacked: u64, archived: u64) -> Option<CommitSizesEntry> {
unsafe {
from_glib_full(ffi::ostree_commit_sizes_entry_new(checksum.to_glib_none().0, objtype.into_glib(), unpacked, archived))
}
}
}

76
rust-bindings/src/auto/constants.rs generated Normal file
View File

@ -0,0 +1,76 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use std::ffi::CStr;
#[doc(alias = "OSTREE_COMMIT_GVARIANT_STRING")]
pub static COMMIT_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_GVARIANT_STRING).to_str().unwrap()});
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_ARCHITECTURE")]
pub static COMMIT_META_KEY_ARCHITECTURE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_ARCHITECTURE).to_str().unwrap()});
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_COLLECTION_BINDING")]
pub static COMMIT_META_KEY_COLLECTION_BINDING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_COLLECTION_BINDING).to_str().unwrap()});
#[cfg(any(feature = "v2017_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_ENDOFLIFE")]
pub static COMMIT_META_KEY_ENDOFLIFE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_ENDOFLIFE).to_str().unwrap()});
#[cfg(any(feature = "v2017_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_ENDOFLIFE_REBASE")]
pub static COMMIT_META_KEY_ENDOFLIFE_REBASE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_ENDOFLIFE_REBASE).to_str().unwrap()});
#[cfg(any(feature = "v2017_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_9")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_REF_BINDING")]
pub static COMMIT_META_KEY_REF_BINDING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_REF_BINDING).to_str().unwrap()});
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_SOURCE_TITLE")]
pub static COMMIT_META_KEY_SOURCE_TITLE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_SOURCE_TITLE).to_str().unwrap()});
#[cfg(any(feature = "v2014_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2014_9")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_VERSION")]
pub static COMMIT_META_KEY_VERSION: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_VERSION).to_str().unwrap()});
#[doc(alias = "OSTREE_DIRMETA_GVARIANT_STRING")]
pub static DIRMETA_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_DIRMETA_GVARIANT_STRING).to_str().unwrap()});
#[doc(alias = "OSTREE_FILEMETA_GVARIANT_STRING")]
pub static FILEMETA_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_FILEMETA_GVARIANT_STRING).to_str().unwrap()});
#[doc(alias = "OSTREE_GPG_KEY_GVARIANT_STRING")]
pub static GPG_KEY_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_GPG_KEY_GVARIANT_STRING).to_str().unwrap()});
#[cfg(any(feature = "v2021_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_1")))]
#[doc(alias = "OSTREE_METADATA_KEY_BOOTABLE")]
pub static METADATA_KEY_BOOTABLE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_METADATA_KEY_BOOTABLE).to_str().unwrap()});
#[cfg(any(feature = "v2021_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_1")))]
#[doc(alias = "OSTREE_METADATA_KEY_LINUX")]
pub static METADATA_KEY_LINUX: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_METADATA_KEY_LINUX).to_str().unwrap()});
#[cfg(any(feature = "v2018_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_9")))]
#[doc(alias = "OSTREE_META_KEY_DEPLOY_COLLECTION_ID")]
pub static META_KEY_DEPLOY_COLLECTION_ID: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_META_KEY_DEPLOY_COLLECTION_ID).to_str().unwrap()});
#[cfg(any(feature = "v2018_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_3")))]
#[doc(alias = "OSTREE_ORIGIN_TRANSIENT_GROUP")]
pub static ORIGIN_TRANSIENT_GROUP: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_ORIGIN_TRANSIENT_GROUP).to_str().unwrap()});
#[cfg(any(feature = "v2022_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2022_2")))]
#[doc(alias = "OSTREE_PATH_BOOTED")]
pub static PATH_BOOTED: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_PATH_BOOTED).to_str().unwrap()});
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
#[doc(alias = "OSTREE_REPO_METADATA_REF")]
pub static REPO_METADATA_REF: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_REPO_METADATA_REF).to_str().unwrap()});
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
#[doc(alias = "OSTREE_SIGN_NAME_ED25519")]
pub static SIGN_NAME_ED25519: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_SIGN_NAME_ED25519).to_str().unwrap()});
#[doc(alias = "OSTREE_SUMMARY_GVARIANT_STRING")]
pub static SUMMARY_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_SUMMARY_GVARIANT_STRING).to_str().unwrap()});
#[doc(alias = "OSTREE_SUMMARY_SIG_GVARIANT_STRING")]
pub static SUMMARY_SIG_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_SUMMARY_SIG_GVARIANT_STRING).to_str().unwrap()});
#[doc(alias = "OSTREE_TREE_GVARIANT_STRING")]
pub static TREE_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_TREE_GVARIANT_STRING).to_str().unwrap()});

34
rust-bindings/src/auto/content_writer.rs generated Normal file
View File

@ -0,0 +1,34 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeContentWriter")]
pub struct ContentWriter(Object<ffi::OstreeContentWriter, ffi::OstreeContentWriterClass>) @extends gio::OutputStream;
match fn {
type_ => || ffi::ostree_content_writer_get_type(),
}
}
impl ContentWriter {
#[doc(alias = "ostree_content_writer_finish")]
pub fn finish<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<glib::GString, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_content_writer_finish(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
}
impl fmt::Display for ContentWriter {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("ContentWriter")
}
}

201
rust-bindings/src/auto/deployment.rs generated Normal file
View File

@ -0,0 +1,201 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::BootconfigParser;
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
use crate::DeploymentUnlockedState;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
#[doc(alias = "OstreeDeployment")]
pub struct Deployment(Object<ffi::OstreeDeployment>);
match fn {
type_ => || ffi::ostree_deployment_get_type(),
}
}
impl Deployment {
#[doc(alias = "ostree_deployment_new")]
pub fn new(index: i32, osname: &str, csum: &str, deployserial: i32, bootcsum: Option<&str>, bootserial: i32) -> Deployment {
unsafe {
from_glib_full(ffi::ostree_deployment_new(index, osname.to_glib_none().0, csum.to_glib_none().0, deployserial, bootcsum.to_glib_none().0, bootserial))
}
}
#[doc(alias = "ostree_deployment_clone")]
pub fn clone(&self) -> Option<Deployment> {
unsafe {
from_glib_full(ffi::ostree_deployment_clone(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_equal")]
pub fn equal(&self, bp: &Deployment) -> bool {
unsafe {
from_glib(ffi::ostree_deployment_equal(ToGlibPtr::<*mut ffi::OstreeDeployment>::to_glib_none(self).0 as glib::ffi::gconstpointer, ToGlibPtr::<*mut ffi::OstreeDeployment>::to_glib_none(bp).0 as glib::ffi::gconstpointer))
}
}
#[doc(alias = "ostree_deployment_get_bootconfig")]
#[doc(alias = "get_bootconfig")]
pub fn bootconfig(&self) -> Option<BootconfigParser> {
unsafe {
from_glib_none(ffi::ostree_deployment_get_bootconfig(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_get_bootcsum")]
#[doc(alias = "get_bootcsum")]
pub fn bootcsum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_deployment_get_bootcsum(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_get_bootserial")]
#[doc(alias = "get_bootserial")]
pub fn bootserial(&self) -> i32 {
unsafe {
ffi::ostree_deployment_get_bootserial(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_deployment_get_csum")]
#[doc(alias = "get_csum")]
pub fn csum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_deployment_get_csum(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_get_deployserial")]
#[doc(alias = "get_deployserial")]
pub fn deployserial(&self) -> i32 {
unsafe {
ffi::ostree_deployment_get_deployserial(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_deployment_get_index")]
#[doc(alias = "get_index")]
pub fn index(&self) -> i32 {
unsafe {
ffi::ostree_deployment_get_index(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_deployment_get_origin")]
#[doc(alias = "get_origin")]
pub fn origin(&self) -> Option<glib::KeyFile> {
unsafe {
from_glib_none(ffi::ostree_deployment_get_origin(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_get_origin_relpath")]
#[doc(alias = "get_origin_relpath")]
pub fn origin_relpath(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_deployment_get_origin_relpath(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_get_osname")]
#[doc(alias = "get_osname")]
pub fn osname(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_deployment_get_osname(self.to_glib_none().0))
}
}
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
#[doc(alias = "ostree_deployment_get_unlocked")]
#[doc(alias = "get_unlocked")]
pub fn unlocked(&self) -> DeploymentUnlockedState {
unsafe {
from_glib(ffi::ostree_deployment_get_unlocked(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_hash")]
pub fn hash(&self) -> u32 {
unsafe {
ffi::ostree_deployment_hash(ToGlibPtr::<*mut ffi::OstreeDeployment>::to_glib_none(self).0 as glib::ffi::gconstpointer)
}
}
#[cfg(any(feature = "v2018_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_3")))]
#[doc(alias = "ostree_deployment_is_pinned")]
pub fn is_pinned(&self) -> bool {
unsafe {
from_glib(ffi::ostree_deployment_is_pinned(self.to_glib_none().0))
}
}
#[cfg(any(feature = "v2018_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_3")))]
#[doc(alias = "ostree_deployment_is_staged")]
pub fn is_staged(&self) -> bool {
unsafe {
from_glib(ffi::ostree_deployment_is_staged(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_set_bootconfig")]
pub fn set_bootconfig(&self, bootconfig: Option<&BootconfigParser>) {
unsafe {
ffi::ostree_deployment_set_bootconfig(self.to_glib_none().0, bootconfig.to_glib_none().0);
}
}
#[doc(alias = "ostree_deployment_set_bootserial")]
pub fn set_bootserial(&self, index: i32) {
unsafe {
ffi::ostree_deployment_set_bootserial(self.to_glib_none().0, index);
}
}
#[doc(alias = "ostree_deployment_set_index")]
pub fn set_index(&self, index: i32) {
unsafe {
ffi::ostree_deployment_set_index(self.to_glib_none().0, index);
}
}
#[doc(alias = "ostree_deployment_set_origin")]
pub fn set_origin(&self, origin: Option<&glib::KeyFile>) {
unsafe {
ffi::ostree_deployment_set_origin(self.to_glib_none().0, origin.to_glib_none().0);
}
}
#[cfg(any(feature = "v2018_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_3")))]
#[doc(alias = "ostree_deployment_origin_remove_transient_state")]
pub fn origin_remove_transient_state(origin: &glib::KeyFile) {
unsafe {
ffi::ostree_deployment_origin_remove_transient_state(origin.to_glib_none().0);
}
}
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
#[doc(alias = "ostree_deployment_unlocked_state_to_string")]
pub fn unlocked_state_to_string(state: DeploymentUnlockedState) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_deployment_unlocked_state_to_string(state.into_glib()))
}
}
}
impl fmt::Display for Deployment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Deployment")
}
}

15
rust-bindings/src/auto/diff_item.rs generated Normal file
View File

@ -0,0 +1,15 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct DiffItem(Shared<ffi::OstreeDiffItem>);
match fn {
ref => |ptr| ffi::ostree_diff_item_ref(ptr),
unref => |ptr| ffi::ostree_diff_item_unref(ptr),
type_ => || ffi::ostree_diff_item_get_type(),
}
}

692
rust-bindings/src/auto/enums.rs generated Normal file
View File

@ -0,0 +1,692 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::translate::*;
use std::fmt;
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeDeploymentUnlockedState")]
pub enum DeploymentUnlockedState {
#[doc(alias = "OSTREE_DEPLOYMENT_UNLOCKED_NONE")]
None,
#[doc(alias = "OSTREE_DEPLOYMENT_UNLOCKED_DEVELOPMENT")]
Development,
#[doc(alias = "OSTREE_DEPLOYMENT_UNLOCKED_HOTFIX")]
Hotfix,
#[doc(alias = "OSTREE_DEPLOYMENT_UNLOCKED_TRANSIENT")]
Transient,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for DeploymentUnlockedState {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "DeploymentUnlockedState::{}", match *self {
Self::None => "None",
Self::Development => "Development",
Self::Hotfix => "Hotfix",
Self::Transient => "Transient",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for DeploymentUnlockedState {
type GlibType = ffi::OstreeDeploymentUnlockedState;
fn into_glib(self) -> ffi::OstreeDeploymentUnlockedState {
match self {
Self::None => ffi::OSTREE_DEPLOYMENT_UNLOCKED_NONE,
Self::Development => ffi::OSTREE_DEPLOYMENT_UNLOCKED_DEVELOPMENT,
Self::Hotfix => ffi::OSTREE_DEPLOYMENT_UNLOCKED_HOTFIX,
Self::Transient => ffi::OSTREE_DEPLOYMENT_UNLOCKED_TRANSIENT,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeDeploymentUnlockedState> for DeploymentUnlockedState {
unsafe fn from_glib(value: ffi::OstreeDeploymentUnlockedState) -> Self {
match value {
ffi::OSTREE_DEPLOYMENT_UNLOCKED_NONE => Self::None,
ffi::OSTREE_DEPLOYMENT_UNLOCKED_DEVELOPMENT => Self::Development,
ffi::OSTREE_DEPLOYMENT_UNLOCKED_HOTFIX => Self::Hotfix,
ffi::OSTREE_DEPLOYMENT_UNLOCKED_TRANSIENT => Self::Transient,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeGpgSignatureAttr")]
pub enum GpgSignatureAttr {
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_VALID")]
Valid,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED")]
SigExpired,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_KEY_EXPIRED")]
KeyExpired,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_KEY_REVOKED")]
KeyRevoked,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING")]
KeyMissing,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT")]
Fingerprint,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_TIMESTAMP")]
Timestamp,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_EXP_TIMESTAMP")]
ExpTimestamp,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_PUBKEY_ALGO_NAME")]
PubkeyAlgoName,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_HASH_ALGO_NAME")]
HashAlgoName,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_USER_NAME")]
UserName,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL")]
UserEmail,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT_PRIMARY")]
FingerprintPrimary,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP")]
KeyExpTimestamp,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY")]
KeyExpTimestampPrimary,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for GpgSignatureAttr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "GpgSignatureAttr::{}", match *self {
Self::Valid => "Valid",
Self::SigExpired => "SigExpired",
Self::KeyExpired => "KeyExpired",
Self::KeyRevoked => "KeyRevoked",
Self::KeyMissing => "KeyMissing",
Self::Fingerprint => "Fingerprint",
Self::Timestamp => "Timestamp",
Self::ExpTimestamp => "ExpTimestamp",
Self::PubkeyAlgoName => "PubkeyAlgoName",
Self::HashAlgoName => "HashAlgoName",
Self::UserName => "UserName",
Self::UserEmail => "UserEmail",
Self::FingerprintPrimary => "FingerprintPrimary",
Self::KeyExpTimestamp => "KeyExpTimestamp",
Self::KeyExpTimestampPrimary => "KeyExpTimestampPrimary",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for GpgSignatureAttr {
type GlibType = ffi::OstreeGpgSignatureAttr;
fn into_glib(self) -> ffi::OstreeGpgSignatureAttr {
match self {
Self::Valid => ffi::OSTREE_GPG_SIGNATURE_ATTR_VALID,
Self::SigExpired => ffi::OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED,
Self::KeyExpired => ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_EXPIRED,
Self::KeyRevoked => ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_REVOKED,
Self::KeyMissing => ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING,
Self::Fingerprint => ffi::OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT,
Self::Timestamp => ffi::OSTREE_GPG_SIGNATURE_ATTR_TIMESTAMP,
Self::ExpTimestamp => ffi::OSTREE_GPG_SIGNATURE_ATTR_EXP_TIMESTAMP,
Self::PubkeyAlgoName => ffi::OSTREE_GPG_SIGNATURE_ATTR_PUBKEY_ALGO_NAME,
Self::HashAlgoName => ffi::OSTREE_GPG_SIGNATURE_ATTR_HASH_ALGO_NAME,
Self::UserName => ffi::OSTREE_GPG_SIGNATURE_ATTR_USER_NAME,
Self::UserEmail => ffi::OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL,
Self::FingerprintPrimary => ffi::OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT_PRIMARY,
Self::KeyExpTimestamp => ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP,
Self::KeyExpTimestampPrimary => ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeGpgSignatureAttr> for GpgSignatureAttr {
unsafe fn from_glib(value: ffi::OstreeGpgSignatureAttr) -> Self {
match value {
ffi::OSTREE_GPG_SIGNATURE_ATTR_VALID => Self::Valid,
ffi::OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED => Self::SigExpired,
ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_EXPIRED => Self::KeyExpired,
ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_REVOKED => Self::KeyRevoked,
ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING => Self::KeyMissing,
ffi::OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT => Self::Fingerprint,
ffi::OSTREE_GPG_SIGNATURE_ATTR_TIMESTAMP => Self::Timestamp,
ffi::OSTREE_GPG_SIGNATURE_ATTR_EXP_TIMESTAMP => Self::ExpTimestamp,
ffi::OSTREE_GPG_SIGNATURE_ATTR_PUBKEY_ALGO_NAME => Self::PubkeyAlgoName,
ffi::OSTREE_GPG_SIGNATURE_ATTR_HASH_ALGO_NAME => Self::HashAlgoName,
ffi::OSTREE_GPG_SIGNATURE_ATTR_USER_NAME => Self::UserName,
ffi::OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL => Self::UserEmail,
ffi::OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT_PRIMARY => Self::FingerprintPrimary,
ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP => Self::KeyExpTimestamp,
ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY => Self::KeyExpTimestampPrimary,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeObjectType")]
pub enum ObjectType {
#[doc(alias = "OSTREE_OBJECT_TYPE_FILE")]
File,
#[doc(alias = "OSTREE_OBJECT_TYPE_DIR_TREE")]
DirTree,
#[doc(alias = "OSTREE_OBJECT_TYPE_DIR_META")]
DirMeta,
#[doc(alias = "OSTREE_OBJECT_TYPE_COMMIT")]
Commit,
#[doc(alias = "OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT")]
TombstoneCommit,
#[doc(alias = "OSTREE_OBJECT_TYPE_COMMIT_META")]
CommitMeta,
#[doc(alias = "OSTREE_OBJECT_TYPE_PAYLOAD_LINK")]
PayloadLink,
#[doc(alias = "OSTREE_OBJECT_TYPE_FILE_XATTRS")]
FileXattrs,
#[doc(alias = "OSTREE_OBJECT_TYPE_FILE_XATTRS_LINK")]
FileXattrsLink,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for ObjectType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "ObjectType::{}", match *self {
Self::File => "File",
Self::DirTree => "DirTree",
Self::DirMeta => "DirMeta",
Self::Commit => "Commit",
Self::TombstoneCommit => "TombstoneCommit",
Self::CommitMeta => "CommitMeta",
Self::PayloadLink => "PayloadLink",
Self::FileXattrs => "FileXattrs",
Self::FileXattrsLink => "FileXattrsLink",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for ObjectType {
type GlibType = ffi::OstreeObjectType;
fn into_glib(self) -> ffi::OstreeObjectType {
match self {
Self::File => ffi::OSTREE_OBJECT_TYPE_FILE,
Self::DirTree => ffi::OSTREE_OBJECT_TYPE_DIR_TREE,
Self::DirMeta => ffi::OSTREE_OBJECT_TYPE_DIR_META,
Self::Commit => ffi::OSTREE_OBJECT_TYPE_COMMIT,
Self::TombstoneCommit => ffi::OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT,
Self::CommitMeta => ffi::OSTREE_OBJECT_TYPE_COMMIT_META,
Self::PayloadLink => ffi::OSTREE_OBJECT_TYPE_PAYLOAD_LINK,
Self::FileXattrs => ffi::OSTREE_OBJECT_TYPE_FILE_XATTRS,
Self::FileXattrsLink => ffi::OSTREE_OBJECT_TYPE_FILE_XATTRS_LINK,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeObjectType> for ObjectType {
unsafe fn from_glib(value: ffi::OstreeObjectType) -> Self {
match value {
ffi::OSTREE_OBJECT_TYPE_FILE => Self::File,
ffi::OSTREE_OBJECT_TYPE_DIR_TREE => Self::DirTree,
ffi::OSTREE_OBJECT_TYPE_DIR_META => Self::DirMeta,
ffi::OSTREE_OBJECT_TYPE_COMMIT => Self::Commit,
ffi::OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT => Self::TombstoneCommit,
ffi::OSTREE_OBJECT_TYPE_COMMIT_META => Self::CommitMeta,
ffi::OSTREE_OBJECT_TYPE_PAYLOAD_LINK => Self::PayloadLink,
ffi::OSTREE_OBJECT_TYPE_FILE_XATTRS => Self::FileXattrs,
ffi::OSTREE_OBJECT_TYPE_FILE_XATTRS_LINK => Self::FileXattrsLink,
value => Self::__Unknown(value),
}
}
}
#[cfg(any(feature = "v2018_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_2")))]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoCheckoutFilterResult")]
pub enum RepoCheckoutFilterResult {
#[doc(alias = "OSTREE_REPO_CHECKOUT_FILTER_ALLOW")]
Allow,
#[doc(alias = "OSTREE_REPO_CHECKOUT_FILTER_SKIP")]
Skip,
#[doc(hidden)]
__Unknown(i32),
}
#[cfg(any(feature = "v2018_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_2")))]
impl fmt::Display for RepoCheckoutFilterResult {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoCheckoutFilterResult::{}", match *self {
Self::Allow => "Allow",
Self::Skip => "Skip",
_ => "Unknown",
})
}
}
#[cfg(any(feature = "v2018_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_2")))]
#[doc(hidden)]
impl IntoGlib for RepoCheckoutFilterResult {
type GlibType = ffi::OstreeRepoCheckoutFilterResult;
fn into_glib(self) -> ffi::OstreeRepoCheckoutFilterResult {
match self {
Self::Allow => ffi::OSTREE_REPO_CHECKOUT_FILTER_ALLOW,
Self::Skip => ffi::OSTREE_REPO_CHECKOUT_FILTER_SKIP,
Self::__Unknown(value) => value,
}
}
}
#[cfg(any(feature = "v2018_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_2")))]
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCheckoutFilterResult> for RepoCheckoutFilterResult {
unsafe fn from_glib(value: ffi::OstreeRepoCheckoutFilterResult) -> Self {
match value {
ffi::OSTREE_REPO_CHECKOUT_FILTER_ALLOW => Self::Allow,
ffi::OSTREE_REPO_CHECKOUT_FILTER_SKIP => Self::Skip,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoCheckoutMode")]
pub enum RepoCheckoutMode {
#[doc(alias = "OSTREE_REPO_CHECKOUT_MODE_NONE")]
None,
#[doc(alias = "OSTREE_REPO_CHECKOUT_MODE_USER")]
User,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for RepoCheckoutMode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoCheckoutMode::{}", match *self {
Self::None => "None",
Self::User => "User",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for RepoCheckoutMode {
type GlibType = ffi::OstreeRepoCheckoutMode;
fn into_glib(self) -> ffi::OstreeRepoCheckoutMode {
match self {
Self::None => ffi::OSTREE_REPO_CHECKOUT_MODE_NONE,
Self::User => ffi::OSTREE_REPO_CHECKOUT_MODE_USER,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCheckoutMode> for RepoCheckoutMode {
unsafe fn from_glib(value: ffi::OstreeRepoCheckoutMode) -> Self {
match value {
ffi::OSTREE_REPO_CHECKOUT_MODE_NONE => Self::None,
ffi::OSTREE_REPO_CHECKOUT_MODE_USER => Self::User,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoCheckoutOverwriteMode")]
pub enum RepoCheckoutOverwriteMode {
#[doc(alias = "OSTREE_REPO_CHECKOUT_OVERWRITE_NONE")]
None,
#[doc(alias = "OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES")]
UnionFiles,
#[doc(alias = "OSTREE_REPO_CHECKOUT_OVERWRITE_ADD_FILES")]
AddFiles,
#[doc(alias = "OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL")]
UnionIdentical,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for RepoCheckoutOverwriteMode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoCheckoutOverwriteMode::{}", match *self {
Self::None => "None",
Self::UnionFiles => "UnionFiles",
Self::AddFiles => "AddFiles",
Self::UnionIdentical => "UnionIdentical",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for RepoCheckoutOverwriteMode {
type GlibType = ffi::OstreeRepoCheckoutOverwriteMode;
fn into_glib(self) -> ffi::OstreeRepoCheckoutOverwriteMode {
match self {
Self::None => ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_NONE,
Self::UnionFiles => ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES,
Self::AddFiles => ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_ADD_FILES,
Self::UnionIdentical => ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCheckoutOverwriteMode> for RepoCheckoutOverwriteMode {
unsafe fn from_glib(value: ffi::OstreeRepoCheckoutOverwriteMode) -> Self {
match value {
ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_NONE => Self::None,
ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES => Self::UnionFiles,
ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_ADD_FILES => Self::AddFiles,
ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL => Self::UnionIdentical,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoCommitFilterResult")]
pub enum RepoCommitFilterResult {
#[doc(alias = "OSTREE_REPO_COMMIT_FILTER_ALLOW")]
Allow,
#[doc(alias = "OSTREE_REPO_COMMIT_FILTER_SKIP")]
Skip,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for RepoCommitFilterResult {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoCommitFilterResult::{}", match *self {
Self::Allow => "Allow",
Self::Skip => "Skip",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for RepoCommitFilterResult {
type GlibType = ffi::OstreeRepoCommitFilterResult;
fn into_glib(self) -> ffi::OstreeRepoCommitFilterResult {
match self {
Self::Allow => ffi::OSTREE_REPO_COMMIT_FILTER_ALLOW,
Self::Skip => ffi::OSTREE_REPO_COMMIT_FILTER_SKIP,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCommitFilterResult> for RepoCommitFilterResult {
unsafe fn from_glib(value: ffi::OstreeRepoCommitFilterResult) -> Self {
match value {
ffi::OSTREE_REPO_COMMIT_FILTER_ALLOW => Self::Allow,
ffi::OSTREE_REPO_COMMIT_FILTER_SKIP => Self::Skip,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoCommitIterResult")]
pub enum RepoCommitIterResult {
#[doc(alias = "OSTREE_REPO_COMMIT_ITER_RESULT_ERROR")]
Error,
#[doc(alias = "OSTREE_REPO_COMMIT_ITER_RESULT_END")]
End,
#[doc(alias = "OSTREE_REPO_COMMIT_ITER_RESULT_FILE")]
File,
#[doc(alias = "OSTREE_REPO_COMMIT_ITER_RESULT_DIR")]
Dir,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for RepoCommitIterResult {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoCommitIterResult::{}", match *self {
Self::Error => "Error",
Self::End => "End",
Self::File => "File",
Self::Dir => "Dir",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for RepoCommitIterResult {
type GlibType = ffi::OstreeRepoCommitIterResult;
fn into_glib(self) -> ffi::OstreeRepoCommitIterResult {
match self {
Self::Error => ffi::OSTREE_REPO_COMMIT_ITER_RESULT_ERROR,
Self::End => ffi::OSTREE_REPO_COMMIT_ITER_RESULT_END,
Self::File => ffi::OSTREE_REPO_COMMIT_ITER_RESULT_FILE,
Self::Dir => ffi::OSTREE_REPO_COMMIT_ITER_RESULT_DIR,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCommitIterResult> for RepoCommitIterResult {
unsafe fn from_glib(value: ffi::OstreeRepoCommitIterResult) -> Self {
match value {
ffi::OSTREE_REPO_COMMIT_ITER_RESULT_ERROR => Self::Error,
ffi::OSTREE_REPO_COMMIT_ITER_RESULT_END => Self::End,
ffi::OSTREE_REPO_COMMIT_ITER_RESULT_FILE => Self::File,
ffi::OSTREE_REPO_COMMIT_ITER_RESULT_DIR => Self::Dir,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoMode")]
pub enum RepoMode {
#[doc(alias = "OSTREE_REPO_MODE_BARE")]
Bare,
#[doc(alias = "OSTREE_REPO_MODE_ARCHIVE")]
Archive,
#[doc(alias = "OSTREE_REPO_MODE_BARE_USER")]
BareUser,
#[doc(alias = "OSTREE_REPO_MODE_BARE_USER_ONLY")]
BareUserOnly,
#[doc(alias = "OSTREE_REPO_MODE_BARE_SPLIT_XATTRS")]
BareSplitXattrs,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for RepoMode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoMode::{}", match *self {
Self::Bare => "Bare",
Self::Archive => "Archive",
Self::BareUser => "BareUser",
Self::BareUserOnly => "BareUserOnly",
Self::BareSplitXattrs => "BareSplitXattrs",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for RepoMode {
type GlibType = ffi::OstreeRepoMode;
fn into_glib(self) -> ffi::OstreeRepoMode {
match self {
Self::Bare => ffi::OSTREE_REPO_MODE_BARE,
Self::Archive => ffi::OSTREE_REPO_MODE_ARCHIVE,
Self::BareUser => ffi::OSTREE_REPO_MODE_BARE_USER,
Self::BareUserOnly => ffi::OSTREE_REPO_MODE_BARE_USER_ONLY,
Self::BareSplitXattrs => ffi::OSTREE_REPO_MODE_BARE_SPLIT_XATTRS,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoMode> for RepoMode {
unsafe fn from_glib(value: ffi::OstreeRepoMode) -> Self {
match value {
ffi::OSTREE_REPO_MODE_BARE => Self::Bare,
ffi::OSTREE_REPO_MODE_ARCHIVE => Self::Archive,
ffi::OSTREE_REPO_MODE_BARE_USER => Self::BareUser,
ffi::OSTREE_REPO_MODE_BARE_USER_ONLY => Self::BareUserOnly,
ffi::OSTREE_REPO_MODE_BARE_SPLIT_XATTRS => Self::BareSplitXattrs,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoRemoteChange")]
pub enum RepoRemoteChange {
#[doc(alias = "OSTREE_REPO_REMOTE_CHANGE_ADD")]
Add,
#[doc(alias = "OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS")]
AddIfNotExists,
#[doc(alias = "OSTREE_REPO_REMOTE_CHANGE_DELETE")]
Delete,
#[doc(alias = "OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS")]
DeleteIfExists,
#[doc(alias = "OSTREE_REPO_REMOTE_CHANGE_REPLACE")]
Replace,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for RepoRemoteChange {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoRemoteChange::{}", match *self {
Self::Add => "Add",
Self::AddIfNotExists => "AddIfNotExists",
Self::Delete => "Delete",
Self::DeleteIfExists => "DeleteIfExists",
Self::Replace => "Replace",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for RepoRemoteChange {
type GlibType = ffi::OstreeRepoRemoteChange;
fn into_glib(self) -> ffi::OstreeRepoRemoteChange {
match self {
Self::Add => ffi::OSTREE_REPO_REMOTE_CHANGE_ADD,
Self::AddIfNotExists => ffi::OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS,
Self::Delete => ffi::OSTREE_REPO_REMOTE_CHANGE_DELETE,
Self::DeleteIfExists => ffi::OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS,
Self::Replace => ffi::OSTREE_REPO_REMOTE_CHANGE_REPLACE,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoRemoteChange> for RepoRemoteChange {
unsafe fn from_glib(value: ffi::OstreeRepoRemoteChange) -> Self {
match value {
ffi::OSTREE_REPO_REMOTE_CHANGE_ADD => Self::Add,
ffi::OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS => Self::AddIfNotExists,
ffi::OSTREE_REPO_REMOTE_CHANGE_DELETE => Self::Delete,
ffi::OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS => Self::DeleteIfExists,
ffi::OSTREE_REPO_REMOTE_CHANGE_REPLACE => Self::Replace,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeStaticDeltaGenerateOpt")]
pub enum StaticDeltaGenerateOpt {
#[doc(alias = "OSTREE_STATIC_DELTA_GENERATE_OPT_LOWLATENCY")]
Lowlatency,
#[doc(alias = "OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR")]
Major,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for StaticDeltaGenerateOpt {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "StaticDeltaGenerateOpt::{}", match *self {
Self::Lowlatency => "Lowlatency",
Self::Major => "Major",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for StaticDeltaGenerateOpt {
type GlibType = ffi::OstreeStaticDeltaGenerateOpt;
fn into_glib(self) -> ffi::OstreeStaticDeltaGenerateOpt {
match self {
Self::Lowlatency => ffi::OSTREE_STATIC_DELTA_GENERATE_OPT_LOWLATENCY,
Self::Major => ffi::OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeStaticDeltaGenerateOpt> for StaticDeltaGenerateOpt {
unsafe fn from_glib(value: ffi::OstreeStaticDeltaGenerateOpt) -> Self {
match value {
ffi::OSTREE_STATIC_DELTA_GENERATE_OPT_LOWLATENCY => Self::Lowlatency,
ffi::OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR => Self::Major,
value => Self::__Unknown(value),
}
}
}

626
rust-bindings/src/auto/flags.rs generated Normal file
View File

@ -0,0 +1,626 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use bitflags::bitflags;
use glib::translate::*;
use glib::value::FromValue;
use glib::value::ToValue;
use glib::StaticType;
use glib::Type;
use std::fmt;
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
bitflags! {
#[doc(alias = "OstreeChecksumFlags")]
pub struct ChecksumFlags: u32 {
#[doc(alias = "OSTREE_CHECKSUM_FLAGS_NONE")]
const NONE = ffi::OSTREE_CHECKSUM_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS")]
const IGNORE_XATTRS = ffi::OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS as u32;
#[doc(alias = "OSTREE_CHECKSUM_FLAGS_CANONICAL_PERMISSIONS")]
const CANONICAL_PERMISSIONS = ffi::OSTREE_CHECKSUM_FLAGS_CANONICAL_PERMISSIONS as u32;
}
}
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
impl fmt::Display for ChecksumFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
#[doc(hidden)]
impl IntoGlib for ChecksumFlags {
type GlibType = ffi::OstreeChecksumFlags;
fn into_glib(self) -> ffi::OstreeChecksumFlags {
self.bits()
}
}
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
#[doc(hidden)]
impl FromGlib<ffi::OstreeChecksumFlags> for ChecksumFlags {
unsafe fn from_glib(value: ffi::OstreeChecksumFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeDiffFlags")]
pub struct DiffFlags: u32 {
#[doc(alias = "OSTREE_DIFF_FLAGS_NONE")]
const NONE = ffi::OSTREE_DIFF_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_DIFF_FLAGS_IGNORE_XATTRS")]
const IGNORE_XATTRS = ffi::OSTREE_DIFF_FLAGS_IGNORE_XATTRS as u32;
}
}
impl fmt::Display for DiffFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for DiffFlags {
type GlibType = ffi::OstreeDiffFlags;
fn into_glib(self) -> ffi::OstreeDiffFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeDiffFlags> for DiffFlags {
unsafe fn from_glib(value: ffi::OstreeDiffFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeGpgSignatureFormatFlags")]
pub struct GpgSignatureFormatFlags: u32 {
#[doc(alias = "OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT")]
const GPG_SIGNATURE_FORMAT_DEFAULT = ffi::OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT as u32;
}
}
impl fmt::Display for GpgSignatureFormatFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for GpgSignatureFormatFlags {
type GlibType = ffi::OstreeGpgSignatureFormatFlags;
fn into_glib(self) -> ffi::OstreeGpgSignatureFormatFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeGpgSignatureFormatFlags> for GpgSignatureFormatFlags {
unsafe fn from_glib(value: ffi::OstreeGpgSignatureFormatFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoCommitModifierFlags")]
pub struct RepoCommitModifierFlags: u32 {
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE")]
const NONE = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS")]
const SKIP_XATTRS = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES")]
const GENERATE_SIZES = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS")]
const CANONICAL_PERMISSIONS = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_ERROR_ON_UNLABELED")]
const ERROR_ON_UNLABELED = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_ERROR_ON_UNLABELED as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME")]
const CONSUME = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_DEVINO_CANONICAL")]
const DEVINO_CANONICAL = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_DEVINO_CANONICAL as u32;
}
}
impl fmt::Display for RepoCommitModifierFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoCommitModifierFlags {
type GlibType = ffi::OstreeRepoCommitModifierFlags;
fn into_glib(self) -> ffi::OstreeRepoCommitModifierFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCommitModifierFlags> for RepoCommitModifierFlags {
unsafe fn from_glib(value: ffi::OstreeRepoCommitModifierFlags) -> Self {
Self::from_bits_truncate(value)
}
}
#[cfg(any(feature = "v2015_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2015_7")))]
bitflags! {
#[doc(alias = "OstreeRepoCommitState")]
pub struct RepoCommitState: u32 {
#[doc(alias = "OSTREE_REPO_COMMIT_STATE_NORMAL")]
const NORMAL = ffi::OSTREE_REPO_COMMIT_STATE_NORMAL as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_STATE_PARTIAL")]
const PARTIAL = ffi::OSTREE_REPO_COMMIT_STATE_PARTIAL as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL")]
const FSCK_PARTIAL = ffi::OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL as u32;
}
}
#[cfg(any(feature = "v2015_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2015_7")))]
impl fmt::Display for RepoCommitState {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[cfg(any(feature = "v2015_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2015_7")))]
#[doc(hidden)]
impl IntoGlib for RepoCommitState {
type GlibType = ffi::OstreeRepoCommitState;
fn into_glib(self) -> ffi::OstreeRepoCommitState {
self.bits()
}
}
#[cfg(any(feature = "v2015_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2015_7")))]
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCommitState> for RepoCommitState {
unsafe fn from_glib(value: ffi::OstreeRepoCommitState) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoCommitTraverseFlags")]
pub struct RepoCommitTraverseFlags: u32 {
#[doc(alias = "OSTREE_REPO_COMMIT_TRAVERSE_FLAG_NONE")]
const NONE = ffi::OSTREE_REPO_COMMIT_TRAVERSE_FLAG_NONE as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_TRAVERSE_FLAG_COMMIT_ONLY")]
const COMMIT_ONLY = ffi::OSTREE_REPO_COMMIT_TRAVERSE_FLAG_COMMIT_ONLY as u32;
}
}
impl fmt::Display for RepoCommitTraverseFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoCommitTraverseFlags {
type GlibType = ffi::OstreeRepoCommitTraverseFlags;
fn into_glib(self) -> ffi::OstreeRepoCommitTraverseFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCommitTraverseFlags> for RepoCommitTraverseFlags {
unsafe fn from_glib(value: ffi::OstreeRepoCommitTraverseFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoListObjectsFlags")]
pub struct RepoListObjectsFlags: u32 {
#[doc(alias = "OSTREE_REPO_LIST_OBJECTS_LOOSE")]
const LOOSE = ffi::OSTREE_REPO_LIST_OBJECTS_LOOSE as u32;
#[doc(alias = "OSTREE_REPO_LIST_OBJECTS_PACKED")]
const PACKED = ffi::OSTREE_REPO_LIST_OBJECTS_PACKED as u32;
#[doc(alias = "OSTREE_REPO_LIST_OBJECTS_ALL")]
const ALL = ffi::OSTREE_REPO_LIST_OBJECTS_ALL as u32;
#[doc(alias = "OSTREE_REPO_LIST_OBJECTS_NO_PARENTS")]
const NO_PARENTS = ffi::OSTREE_REPO_LIST_OBJECTS_NO_PARENTS as u32;
}
}
impl fmt::Display for RepoListObjectsFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoListObjectsFlags {
type GlibType = ffi::OstreeRepoListObjectsFlags;
fn into_glib(self) -> ffi::OstreeRepoListObjectsFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoListObjectsFlags> for RepoListObjectsFlags {
unsafe fn from_glib(value: ffi::OstreeRepoListObjectsFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoListRefsExtFlags")]
pub struct RepoListRefsExtFlags: u32 {
#[doc(alias = "OSTREE_REPO_LIST_REFS_EXT_NONE")]
const NONE = ffi::OSTREE_REPO_LIST_REFS_EXT_NONE as u32;
#[doc(alias = "OSTREE_REPO_LIST_REFS_EXT_ALIASES")]
const ALIASES = ffi::OSTREE_REPO_LIST_REFS_EXT_ALIASES as u32;
#[doc(alias = "OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES")]
const EXCLUDE_REMOTES = ffi::OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES as u32;
#[doc(alias = "OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS")]
const EXCLUDE_MIRRORS = ffi::OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS as u32;
}
}
impl fmt::Display for RepoListRefsExtFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoListRefsExtFlags {
type GlibType = ffi::OstreeRepoListRefsExtFlags;
fn into_glib(self) -> ffi::OstreeRepoListRefsExtFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoListRefsExtFlags> for RepoListRefsExtFlags {
unsafe fn from_glib(value: ffi::OstreeRepoListRefsExtFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoPruneFlags")]
pub struct RepoPruneFlags: u32 {
#[doc(alias = "OSTREE_REPO_PRUNE_FLAGS_NONE")]
const NONE = ffi::OSTREE_REPO_PRUNE_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE")]
const NO_PRUNE = ffi::OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE as u32;
#[doc(alias = "OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY")]
const REFS_ONLY = ffi::OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY as u32;
#[doc(alias = "OSTREE_REPO_PRUNE_FLAGS_COMMIT_ONLY")]
const COMMIT_ONLY = ffi::OSTREE_REPO_PRUNE_FLAGS_COMMIT_ONLY as u32;
}
}
impl fmt::Display for RepoPruneFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoPruneFlags {
type GlibType = ffi::OstreeRepoPruneFlags;
fn into_glib(self) -> ffi::OstreeRepoPruneFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoPruneFlags> for RepoPruneFlags {
unsafe fn from_glib(value: ffi::OstreeRepoPruneFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoPullFlags")]
pub struct RepoPullFlags: u32 {
#[doc(alias = "OSTREE_REPO_PULL_FLAGS_NONE")]
const NONE = ffi::OSTREE_REPO_PULL_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_REPO_PULL_FLAGS_MIRROR")]
const MIRROR = ffi::OSTREE_REPO_PULL_FLAGS_MIRROR as u32;
#[doc(alias = "OSTREE_REPO_PULL_FLAGS_COMMIT_ONLY")]
const COMMIT_ONLY = ffi::OSTREE_REPO_PULL_FLAGS_COMMIT_ONLY as u32;
#[doc(alias = "OSTREE_REPO_PULL_FLAGS_UNTRUSTED")]
const UNTRUSTED = ffi::OSTREE_REPO_PULL_FLAGS_UNTRUSTED as u32;
#[doc(alias = "OSTREE_REPO_PULL_FLAGS_BAREUSERONLY_FILES")]
const BAREUSERONLY_FILES = ffi::OSTREE_REPO_PULL_FLAGS_BAREUSERONLY_FILES as u32;
#[doc(alias = "OSTREE_REPO_PULL_FLAGS_TRUSTED_HTTP")]
const TRUSTED_HTTP = ffi::OSTREE_REPO_PULL_FLAGS_TRUSTED_HTTP as u32;
}
}
impl fmt::Display for RepoPullFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoPullFlags {
type GlibType = ffi::OstreeRepoPullFlags;
fn into_glib(self) -> ffi::OstreeRepoPullFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoPullFlags> for RepoPullFlags {
unsafe fn from_glib(value: ffi::OstreeRepoPullFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoResolveRevExtFlags")]
pub struct RepoResolveRevExtFlags: u32 {
#[doc(alias = "OSTREE_REPO_RESOLVE_REV_EXT_NONE")]
const NONE = ffi::OSTREE_REPO_RESOLVE_REV_EXT_NONE as u32;
#[doc(alias = "OSTREE_REPO_RESOLVE_REV_EXT_LOCAL_ONLY")]
const LOCAL_ONLY = ffi::OSTREE_REPO_RESOLVE_REV_EXT_LOCAL_ONLY as u32;
}
}
impl fmt::Display for RepoResolveRevExtFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoResolveRevExtFlags {
type GlibType = ffi::OstreeRepoResolveRevExtFlags;
fn into_glib(self) -> ffi::OstreeRepoResolveRevExtFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoResolveRevExtFlags> for RepoResolveRevExtFlags {
unsafe fn from_glib(value: ffi::OstreeRepoResolveRevExtFlags) -> Self {
Self::from_bits_truncate(value)
}
}
#[cfg(any(feature = "v2021_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_4")))]
bitflags! {
#[doc(alias = "OstreeRepoVerifyFlags")]
pub struct RepoVerifyFlags: u32 {
#[doc(alias = "OSTREE_REPO_VERIFY_FLAGS_NONE")]
const NONE = ffi::OSTREE_REPO_VERIFY_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_REPO_VERIFY_FLAGS_NO_GPG")]
const NO_GPG = ffi::OSTREE_REPO_VERIFY_FLAGS_NO_GPG as u32;
#[doc(alias = "OSTREE_REPO_VERIFY_FLAGS_NO_SIGNAPI")]
const NO_SIGNAPI = ffi::OSTREE_REPO_VERIFY_FLAGS_NO_SIGNAPI as u32;
}
}
#[cfg(any(feature = "v2021_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_4")))]
impl fmt::Display for RepoVerifyFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[cfg(any(feature = "v2021_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_4")))]
#[doc(hidden)]
impl IntoGlib for RepoVerifyFlags {
type GlibType = ffi::OstreeRepoVerifyFlags;
fn into_glib(self) -> ffi::OstreeRepoVerifyFlags {
self.bits()
}
}
#[cfg(any(feature = "v2021_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_4")))]
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoVerifyFlags> for RepoVerifyFlags {
unsafe fn from_glib(value: ffi::OstreeRepoVerifyFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeSePolicyRestoreconFlags")]
pub struct SePolicyRestoreconFlags: u32 {
#[doc(alias = "OSTREE_SEPOLICY_RESTORECON_FLAGS_NONE")]
const NONE = ffi::OSTREE_SEPOLICY_RESTORECON_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_SEPOLICY_RESTORECON_FLAGS_ALLOW_NOLABEL")]
const ALLOW_NOLABEL = ffi::OSTREE_SEPOLICY_RESTORECON_FLAGS_ALLOW_NOLABEL as u32;
#[doc(alias = "OSTREE_SEPOLICY_RESTORECON_FLAGS_KEEP_EXISTING")]
const KEEP_EXISTING = ffi::OSTREE_SEPOLICY_RESTORECON_FLAGS_KEEP_EXISTING as u32;
}
}
impl fmt::Display for SePolicyRestoreconFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for SePolicyRestoreconFlags {
type GlibType = ffi::OstreeSePolicyRestoreconFlags;
fn into_glib(self) -> ffi::OstreeSePolicyRestoreconFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeSePolicyRestoreconFlags> for SePolicyRestoreconFlags {
unsafe fn from_glib(value: ffi::OstreeSePolicyRestoreconFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeSysrootSimpleWriteDeploymentFlags")]
pub struct SysrootSimpleWriteDeploymentFlags: u32 {
#[doc(alias = "OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NONE")]
const NONE = ffi::OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN")]
const RETAIN = ffi::OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN as u32;
#[doc(alias = "OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NOT_DEFAULT")]
const NOT_DEFAULT = ffi::OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NOT_DEFAULT as u32;
#[doc(alias = "OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN")]
const NO_CLEAN = ffi::OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN as u32;
#[doc(alias = "OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_PENDING")]
const RETAIN_PENDING = ffi::OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_PENDING as u32;
#[doc(alias = "OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_ROLLBACK")]
const RETAIN_ROLLBACK = ffi::OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_ROLLBACK as u32;
}
}
impl fmt::Display for SysrootSimpleWriteDeploymentFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for SysrootSimpleWriteDeploymentFlags {
type GlibType = ffi::OstreeSysrootSimpleWriteDeploymentFlags;
fn into_glib(self) -> ffi::OstreeSysrootSimpleWriteDeploymentFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeSysrootSimpleWriteDeploymentFlags> for SysrootSimpleWriteDeploymentFlags {
unsafe fn from_glib(value: ffi::OstreeSysrootSimpleWriteDeploymentFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeSysrootUpgraderFlags")]
pub struct SysrootUpgraderFlags: u32 {
#[doc(alias = "OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED")]
const IGNORE_UNCONFIGURED = ffi::OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED as u32;
#[doc(alias = "OSTREE_SYSROOT_UPGRADER_FLAGS_STAGE")]
const STAGE = ffi::OSTREE_SYSROOT_UPGRADER_FLAGS_STAGE as u32;
}
}
impl fmt::Display for SysrootUpgraderFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for SysrootUpgraderFlags {
type GlibType = ffi::OstreeSysrootUpgraderFlags;
fn into_glib(self) -> ffi::OstreeSysrootUpgraderFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeSysrootUpgraderFlags> for SysrootUpgraderFlags {
unsafe fn from_glib(value: ffi::OstreeSysrootUpgraderFlags) -> Self {
Self::from_bits_truncate(value)
}
}
impl StaticType for SysrootUpgraderFlags {
fn static_type() -> Type {
unsafe { from_glib(ffi::ostree_sysroot_upgrader_flags_get_type()) }
}
}
impl glib::value::ValueType for SysrootUpgraderFlags {
type Type = Self;
}
unsafe impl<'a> FromValue<'a> for SysrootUpgraderFlags {
type Checker = glib::value::GenericValueTypeChecker<Self>;
unsafe fn from_value(value: &'a glib::Value) -> Self {
from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0))
}
}
impl ToValue for SysrootUpgraderFlags {
fn to_value(&self) -> glib::Value {
let mut value = glib::Value::for_value_type::<Self>();
unsafe {
glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib());
}
value
}
fn value_type(&self) -> glib::Type {
Self::static_type()
}
}
bitflags! {
#[doc(alias = "OstreeSysrootUpgraderPullFlags")]
pub struct SysrootUpgraderPullFlags: u32 {
#[doc(alias = "OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_NONE")]
const NONE = ffi::OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_ALLOW_OLDER")]
const ALLOW_OLDER = ffi::OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_ALLOW_OLDER as u32;
#[doc(alias = "OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_SYNTHETIC")]
const SYNTHETIC = ffi::OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_SYNTHETIC as u32;
}
}
impl fmt::Display for SysrootUpgraderPullFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for SysrootUpgraderPullFlags {
type GlibType = ffi::OstreeSysrootUpgraderPullFlags;
fn into_glib(self) -> ffi::OstreeSysrootUpgraderPullFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeSysrootUpgraderPullFlags> for SysrootUpgraderPullFlags {
unsafe fn from_glib(value: ffi::OstreeSysrootUpgraderPullFlags) -> Self {
Self::from_bits_truncate(value)
}
}

385
rust-bindings/src/auto/functions.rs generated Normal file
View File

@ -0,0 +1,385 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
use crate::CommitSizesEntry;
use crate::DiffFlags;
use crate::DiffItem;
use crate::ObjectType;
use glib::object::IsA;
use glib::translate::*;
use std::mem;
use std::ptr;
#[cfg(any(feature = "v2017_15", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_15")))]
#[doc(alias = "ostree_break_hardlink")]
pub fn break_hardlink<P: IsA<gio::Cancellable>>(dfd: i32, path: &str, skip_xattrs: bool, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_break_hardlink(dfd, path.to_glib_none().0, skip_xattrs.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2017_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_4")))]
#[doc(alias = "ostree_check_version")]
pub fn check_version(required_year: u32, required_release: u32) -> bool {
unsafe {
from_glib(ffi::ostree_check_version(required_year, required_release))
}
}
//#[doc(alias = "ostree_checksum_bytes_peek")]
//pub fn checksum_bytes_peek(bytes: &glib::Variant) -> /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32 {
// unsafe { TODO: call ffi:ostree_checksum_bytes_peek() }
//}
//#[doc(alias = "ostree_checksum_bytes_peek_validate")]
//pub fn checksum_bytes_peek_validate(bytes: &glib::Variant) -> Result</*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, glib::Error> {
// unsafe { TODO: call ffi:ostree_checksum_bytes_peek_validate() }
//}
#[doc(alias = "ostree_checksum_from_bytes_v")]
pub fn checksum_from_bytes_v(csum_v: &glib::Variant) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_checksum_from_bytes_v(csum_v.to_glib_none().0))
}
}
#[doc(alias = "ostree_checksum_to_bytes_v")]
pub fn checksum_to_bytes_v(checksum: &str) -> Option<glib::Variant> {
unsafe {
from_glib_full(ffi::ostree_checksum_to_bytes_v(checksum.to_glib_none().0))
}
}
#[cfg(any(feature = "v2018_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_2")))]
#[doc(alias = "ostree_commit_get_content_checksum")]
pub fn commit_get_content_checksum(commit_variant: &glib::Variant) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_commit_get_content_checksum(commit_variant.to_glib_none().0))
}
}
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
#[doc(alias = "ostree_commit_get_object_sizes")]
pub fn commit_get_object_sizes(commit_variant: &glib::Variant) -> Result<Vec<CommitSizesEntry>, glib::Error> {
unsafe {
let mut out_sizes_entries = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_commit_get_object_sizes(commit_variant.to_glib_none().0, &mut out_sizes_entries, &mut error);
if error.is_null() { Ok(FromGlibPtrContainer::from_glib_container(out_sizes_entries)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_commit_get_parent")]
pub fn commit_get_parent(commit_variant: &glib::Variant) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_commit_get_parent(commit_variant.to_glib_none().0))
}
}
#[cfg(any(feature = "v2016_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_3")))]
#[doc(alias = "ostree_commit_get_timestamp")]
pub fn commit_get_timestamp(commit_variant: &glib::Variant) -> u64 {
unsafe {
ffi::ostree_commit_get_timestamp(commit_variant.to_glib_none().0)
}
}
//#[cfg(any(feature = "v2021_1", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_1")))]
//#[doc(alias = "ostree_commit_metadata_for_bootable")]
//pub fn commit_metadata_for_bootable<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(root: &P, dict: /*Ignored*/&glib::VariantDict, cancellable: Option<&Q>) -> Result<(), glib::Error> {
// unsafe { TODO: call ffi:ostree_commit_metadata_for_bootable() }
//}
#[doc(alias = "ostree_content_file_parse")]
pub fn content_file_parse<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(compressed: bool, content_path: &P, trusted: bool, cancellable: Option<&Q>) -> Result<(gio::InputStream, gio::FileInfo, glib::Variant), glib::Error> {
unsafe {
let mut out_input = ptr::null_mut();
let mut out_file_info = ptr::null_mut();
let mut out_xattrs = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_content_file_parse(compressed.into_glib(), content_path.as_ref().to_glib_none().0, trusted.into_glib(), &mut out_input, &mut out_file_info, &mut out_xattrs, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok((from_glib_full(out_input), from_glib_full(out_file_info), from_glib_full(out_xattrs))) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_content_file_parse_at")]
pub fn content_file_parse_at<P: IsA<gio::Cancellable>>(compressed: bool, parent_dfd: i32, path: &str, trusted: bool, cancellable: Option<&P>) -> Result<(gio::InputStream, gio::FileInfo, glib::Variant), glib::Error> {
unsafe {
let mut out_input = ptr::null_mut();
let mut out_file_info = ptr::null_mut();
let mut out_xattrs = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_content_file_parse_at(compressed.into_glib(), parent_dfd, path.to_glib_none().0, trusted.into_glib(), &mut out_input, &mut out_file_info, &mut out_xattrs, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok((from_glib_full(out_input), from_glib_full(out_file_info), from_glib_full(out_xattrs))) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_content_stream_parse")]
pub fn content_stream_parse<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(compressed: bool, input: &P, input_length: u64, trusted: bool, cancellable: Option<&Q>) -> Result<(gio::InputStream, gio::FileInfo, glib::Variant), glib::Error> {
unsafe {
let mut out_input = ptr::null_mut();
let mut out_file_info = ptr::null_mut();
let mut out_xattrs = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_content_stream_parse(compressed.into_glib(), input.as_ref().to_glib_none().0, input_length, trusted.into_glib(), &mut out_input, &mut out_file_info, &mut out_xattrs, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok((from_glib_full(out_input), from_glib_full(out_file_info), from_glib_full(out_xattrs))) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_create_directory_metadata")]
pub fn create_directory_metadata(dir_info: &gio::FileInfo, xattrs: Option<&glib::Variant>) -> Option<glib::Variant> {
unsafe {
from_glib_full(ffi::ostree_create_directory_metadata(dir_info.to_glib_none().0, xattrs.to_glib_none().0))
}
}
#[doc(alias = "ostree_diff_dirs")]
pub fn diff_dirs<P: IsA<gio::File>, Q: IsA<gio::File>, R: IsA<gio::Cancellable>>(flags: DiffFlags, a: &P, b: &Q, modified: &[&DiffItem], removed: &[gio::File], added: &[gio::File], cancellable: Option<&R>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_diff_dirs(flags.into_glib(), a.as_ref().to_glib_none().0, b.as_ref().to_glib_none().0, modified.to_glib_none().0, removed.to_glib_none().0, added.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
//#[cfg(any(feature = "v2017_4", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_4")))]
//#[doc(alias = "ostree_diff_dirs_with_options")]
//pub fn diff_dirs_with_options<P: IsA<gio::File>, Q: IsA<gio::File>, R: IsA<gio::Cancellable>>(flags: DiffFlags, a: &P, b: &Q, modified: &[&DiffItem], removed: &[gio::File], added: &[gio::File], options: /*Ignored*/Option<&mut DiffDirsOptions>, cancellable: Option<&R>) -> Result<(), glib::Error> {
// unsafe { TODO: call ffi:ostree_diff_dirs_with_options() }
//}
#[doc(alias = "ostree_diff_print")]
pub fn diff_print<P: IsA<gio::File>, Q: IsA<gio::File>>(a: &P, b: &Q, modified: &[&DiffItem], removed: &[gio::File], added: &[gio::File]) {
unsafe {
ffi::ostree_diff_print(a.as_ref().to_glib_none().0, b.as_ref().to_glib_none().0, modified.to_glib_none().0, removed.to_glib_none().0, added.to_glib_none().0);
}
}
#[cfg(any(feature = "v2017_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_10")))]
#[doc(alias = "ostree_gpg_error_quark")]
pub fn gpg_error_quark() -> glib::Quark {
unsafe {
from_glib(ffi::ostree_gpg_error_quark())
}
}
#[doc(alias = "ostree_metadata_variant_type")]
pub fn metadata_variant_type(objtype: ObjectType) -> Option<glib::VariantType> {
unsafe {
from_glib_none(ffi::ostree_metadata_variant_type(objtype.into_glib()))
}
}
#[doc(alias = "ostree_object_from_string")]
pub fn object_from_string(str: &str) -> (glib::GString, ObjectType) {
unsafe {
let mut out_checksum = ptr::null_mut();
let mut out_objtype = mem::MaybeUninit::uninit();
ffi::ostree_object_from_string(str.to_glib_none().0, &mut out_checksum, out_objtype.as_mut_ptr());
let out_objtype = out_objtype.assume_init();
(from_glib_full(out_checksum), from_glib(out_objtype))
}
}
#[doc(alias = "ostree_object_name_deserialize")]
pub fn object_name_deserialize(variant: &glib::Variant) -> (glib::GString, ObjectType) {
unsafe {
let mut out_checksum = ptr::null();
let mut out_objtype = mem::MaybeUninit::uninit();
ffi::ostree_object_name_deserialize(variant.to_glib_none().0, &mut out_checksum, out_objtype.as_mut_ptr());
let out_objtype = out_objtype.assume_init();
(from_glib_none(out_checksum), from_glib(out_objtype))
}
}
#[doc(alias = "ostree_object_name_serialize")]
pub fn object_name_serialize(checksum: &str, objtype: ObjectType) -> Option<glib::Variant> {
unsafe {
from_glib_none(ffi::ostree_object_name_serialize(checksum.to_glib_none().0, objtype.into_glib()))
}
}
#[doc(alias = "ostree_object_to_string")]
pub fn object_to_string(checksum: &str, objtype: ObjectType) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_object_to_string(checksum.to_glib_none().0, objtype.into_glib()))
}
}
#[doc(alias = "ostree_object_type_from_string")]
pub fn object_type_from_string(str: &str) -> ObjectType {
unsafe {
from_glib(ffi::ostree_object_type_from_string(str.to_glib_none().0))
}
}
#[doc(alias = "ostree_object_type_to_string")]
pub fn object_type_to_string(objtype: ObjectType) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_object_type_to_string(objtype.into_glib()))
}
}
#[doc(alias = "ostree_parse_refspec")]
pub fn parse_refspec(refspec: &str) -> Result<(Option<glib::GString>, glib::GString), glib::Error> {
unsafe {
let mut out_remote = ptr::null_mut();
let mut out_ref = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_parse_refspec(refspec.to_glib_none().0, &mut out_remote, &mut out_ref, &mut error);
if error.is_null() { Ok((from_glib_full(out_remote), from_glib_full(out_ref))) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2016_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_6")))]
#[doc(alias = "ostree_raw_file_to_archive_z2_stream")]
pub fn raw_file_to_archive_z2_stream<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(input: &P, file_info: &gio::FileInfo, xattrs: Option<&glib::Variant>, cancellable: Option<&Q>) -> Result<gio::InputStream, glib::Error> {
unsafe {
let mut out_input = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_raw_file_to_archive_z2_stream(input.as_ref().to_glib_none().0, file_info.to_glib_none().0, xattrs.to_glib_none().0, &mut out_input, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_input)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2017_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_3")))]
#[doc(alias = "ostree_raw_file_to_archive_z2_stream_with_options")]
pub fn raw_file_to_archive_z2_stream_with_options<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(input: &P, file_info: &gio::FileInfo, xattrs: Option<&glib::Variant>, options: Option<&glib::Variant>, cancellable: Option<&Q>) -> Result<gio::InputStream, glib::Error> {
unsafe {
let mut out_input = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_raw_file_to_archive_z2_stream_with_options(input.as_ref().to_glib_none().0, file_info.to_glib_none().0, xattrs.to_glib_none().0, options.to_glib_none().0, &mut out_input, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_input)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_raw_file_to_content_stream")]
pub fn raw_file_to_content_stream<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(input: &P, file_info: &gio::FileInfo, xattrs: Option<&glib::Variant>, cancellable: Option<&Q>) -> Result<(gio::InputStream, u64), glib::Error> {
unsafe {
let mut out_input = ptr::null_mut();
let mut out_length = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
let _ = ffi::ostree_raw_file_to_content_stream(input.as_ref().to_glib_none().0, file_info.to_glib_none().0, xattrs.to_glib_none().0, &mut out_input, out_length.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
let out_length = out_length.assume_init();
if error.is_null() { Ok((from_glib_full(out_input), out_length)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_checksum_string")]
pub fn validate_checksum_string(sha256: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_checksum_string(sha256.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
#[doc(alias = "ostree_validate_collection_id")]
pub fn validate_collection_id(collection_id: Option<&str>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_collection_id(collection_id.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2017_8", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_8")))]
#[doc(alias = "ostree_validate_remote_name")]
pub fn validate_remote_name(remote_name: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_remote_name(remote_name.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_rev")]
pub fn validate_rev(rev: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_rev(rev.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_checksum_string")]
pub fn validate_structureof_checksum_string(checksum: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_checksum_string(checksum.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_commit")]
pub fn validate_structureof_commit(commit: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_commit(commit.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_csum_v")]
pub fn validate_structureof_csum_v(checksum: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_csum_v(checksum.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_dirmeta")]
pub fn validate_structureof_dirmeta(dirmeta: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_dirmeta(dirmeta.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_dirtree")]
pub fn validate_structureof_dirtree(dirtree: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_dirtree(dirtree.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_file_mode")]
pub fn validate_structureof_file_mode(mode: u32) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_file_mode(mode, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_objtype")]
pub fn validate_structureof_objtype(objtype: u8) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_objtype(objtype, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}

View File

@ -0,0 +1,90 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::GpgSignatureFormatFlags;
use glib::translate::*;
use std::fmt;
use std::mem;
#[cfg(any(feature = "v2016_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_6")))]
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeGpgVerifyResult")]
pub struct GpgVerifyResult(Object<ffi::OstreeGpgVerifyResult>);
match fn {
type_ => || ffi::ostree_gpg_verify_result_get_type(),
}
}
impl GpgVerifyResult {
#[doc(alias = "ostree_gpg_verify_result_count_all")]
pub fn count_all(&self) -> u32 {
unsafe {
ffi::ostree_gpg_verify_result_count_all(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_gpg_verify_result_count_valid")]
pub fn count_valid(&self) -> u32 {
unsafe {
ffi::ostree_gpg_verify_result_count_valid(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_gpg_verify_result_describe")]
pub fn describe(&self, signature_index: u32, output_buffer: &mut glib::String, line_prefix: Option<&str>, flags: GpgSignatureFormatFlags) {
unsafe {
ffi::ostree_gpg_verify_result_describe(self.to_glib_none().0, signature_index, output_buffer.to_glib_none_mut().0, line_prefix.to_glib_none().0, flags.into_glib());
}
}
//#[doc(alias = "ostree_gpg_verify_result_get")]
//pub fn get(&self, signature_index: u32, attrs: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 31 }) -> Option<glib::Variant> {
// unsafe { TODO: call ffi:ostree_gpg_verify_result_get() }
//}
#[doc(alias = "ostree_gpg_verify_result_get_all")]
#[doc(alias = "get_all")]
pub fn all(&self, signature_index: u32) -> Option<glib::Variant> {
unsafe {
from_glib_none(ffi::ostree_gpg_verify_result_get_all(self.to_glib_none().0, signature_index))
}
}
#[doc(alias = "ostree_gpg_verify_result_lookup")]
pub fn lookup(&self, key_id: &str) -> Option<u32> {
unsafe {
let mut out_signature_index = mem::MaybeUninit::uninit();
let ret = from_glib(ffi::ostree_gpg_verify_result_lookup(self.to_glib_none().0, key_id.to_glib_none().0, out_signature_index.as_mut_ptr()));
let out_signature_index = out_signature_index.assume_init();
if ret { Some(out_signature_index) } else { None }
}
}
#[cfg(any(feature = "v2016_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_6")))]
#[doc(alias = "ostree_gpg_verify_result_require_valid_signature")]
pub fn require_valid_signature(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_gpg_verify_result_require_valid_signature(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_gpg_verify_result_describe_variant")]
pub fn describe_variant(variant: &glib::Variant, output_buffer: &mut glib::String, line_prefix: Option<&str>, flags: GpgSignatureFormatFlags) {
unsafe {
ffi::ostree_gpg_verify_result_describe_variant(variant.to_glib_none().0, output_buffer.to_glib_none_mut().0, line_prefix.to_glib_none().0, flags.into_glib());
}
}
}
impl fmt::Display for GpgVerifyResult {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("GpgVerifyResult")
}
}

217
rust-bindings/src/auto/mod.rs generated Normal file
View File

@ -0,0 +1,217 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
mod async_progress;
pub use self::async_progress::{AsyncProgress};
mod bootconfig_parser;
pub use self::bootconfig_parser::{BootconfigParser};
mod content_writer;
pub use self::content_writer::{ContentWriter};
mod deployment;
pub use self::deployment::{Deployment};
mod gpg_verify_result;
pub use self::gpg_verify_result::{GpgVerifyResult};
mod mutable_tree;
pub use self::mutable_tree::{MutableTree};
mod repo;
pub use self::repo::{Repo};
mod repo_file;
pub use self::repo_file::{RepoFile};
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod repo_finder;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::repo_finder::{RepoFinder, NONE_REPO_FINDER};
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod repo_finder_avahi;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::repo_finder_avahi::{RepoFinderAvahi};
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod repo_finder_config;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::repo_finder_config::{RepoFinderConfig};
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod repo_finder_mount;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::repo_finder_mount::{RepoFinderMount};
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod repo_finder_override;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::repo_finder_override::{RepoFinderOverride};
mod se_policy;
pub use self::se_policy::{SePolicy};
#[cfg(any(feature = "v2020_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
mod sign;
#[cfg(any(feature = "v2020_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
pub use self::sign::{Sign, NONE_SIGN};
mod sysroot;
pub use self::sysroot::{Sysroot};
mod sysroot_upgrader;
pub use self::sysroot_upgrader::{SysrootUpgrader};
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod collection_ref;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::collection_ref::CollectionRef;
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
mod commit_sizes_entry;
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
pub use self::commit_sizes_entry::CommitSizesEntry;
mod diff_item;
pub use self::diff_item::DiffItem;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod remote;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::remote::Remote;
mod repo_commit_modifier;
pub use self::repo_commit_modifier::RepoCommitModifier;
mod repo_dev_ino_cache;
pub use self::repo_dev_ino_cache::RepoDevInoCache;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod repo_finder_result;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::repo_finder_result::RepoFinderResult;
mod enums;
pub use self::enums::DeploymentUnlockedState;
pub use self::enums::GpgSignatureAttr;
pub use self::enums::ObjectType;
#[cfg(any(feature = "v2018_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_2")))]
pub use self::enums::RepoCheckoutFilterResult;
pub use self::enums::RepoCheckoutMode;
pub use self::enums::RepoCheckoutOverwriteMode;
pub use self::enums::RepoCommitFilterResult;
pub use self::enums::RepoCommitIterResult;
pub use self::enums::RepoMode;
pub use self::enums::RepoRemoteChange;
pub use self::enums::StaticDeltaGenerateOpt;
mod flags;
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
pub use self::flags::ChecksumFlags;
pub use self::flags::DiffFlags;
pub use self::flags::GpgSignatureFormatFlags;
pub use self::flags::RepoCommitModifierFlags;
#[cfg(any(feature = "v2015_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2015_7")))]
pub use self::flags::RepoCommitState;
pub use self::flags::RepoCommitTraverseFlags;
pub use self::flags::RepoListObjectsFlags;
pub use self::flags::RepoListRefsExtFlags;
pub use self::flags::RepoPruneFlags;
pub use self::flags::RepoPullFlags;
pub use self::flags::RepoResolveRevExtFlags;
#[cfg(any(feature = "v2021_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_4")))]
pub use self::flags::RepoVerifyFlags;
pub use self::flags::SePolicyRestoreconFlags;
pub use self::flags::SysrootSimpleWriteDeploymentFlags;
pub use self::flags::SysrootUpgraderFlags;
pub use self::flags::SysrootUpgraderPullFlags;
pub mod functions;
mod constants;
pub use self::constants::COMMIT_GVARIANT_STRING;
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
pub use self::constants::COMMIT_META_KEY_ARCHITECTURE;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::constants::COMMIT_META_KEY_COLLECTION_BINDING;
#[cfg(any(feature = "v2017_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
pub use self::constants::COMMIT_META_KEY_ENDOFLIFE;
#[cfg(any(feature = "v2017_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
pub use self::constants::COMMIT_META_KEY_ENDOFLIFE_REBASE;
#[cfg(any(feature = "v2017_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_9")))]
pub use self::constants::COMMIT_META_KEY_REF_BINDING;
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
pub use self::constants::COMMIT_META_KEY_SOURCE_TITLE;
#[cfg(any(feature = "v2014_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2014_9")))]
pub use self::constants::COMMIT_META_KEY_VERSION;
pub use self::constants::DIRMETA_GVARIANT_STRING;
pub use self::constants::FILEMETA_GVARIANT_STRING;
pub use self::constants::GPG_KEY_GVARIANT_STRING;
#[cfg(any(feature = "v2021_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_1")))]
pub use self::constants::METADATA_KEY_BOOTABLE;
#[cfg(any(feature = "v2021_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_1")))]
pub use self::constants::METADATA_KEY_LINUX;
#[cfg(any(feature = "v2018_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_9")))]
pub use self::constants::META_KEY_DEPLOY_COLLECTION_ID;
#[cfg(any(feature = "v2018_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_3")))]
pub use self::constants::ORIGIN_TRANSIENT_GROUP;
#[cfg(any(feature = "v2022_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2022_2")))]
pub use self::constants::PATH_BOOTED;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::constants::REPO_METADATA_REF;
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
pub use self::constants::SIGN_NAME_ED25519;
pub use self::constants::SUMMARY_GVARIANT_STRING;
pub use self::constants::SUMMARY_SIG_GVARIANT_STRING;
pub use self::constants::TREE_GVARIANT_STRING;
#[doc(hidden)]
pub mod traits {
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use super::repo_finder::RepoFinderExt;
#[cfg(any(feature = "v2020_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
pub use super::sign::SignExt;
}

185
rust-bindings/src/auto/mutable_tree.rs generated Normal file
View File

@ -0,0 +1,185 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
#[cfg(any(feature = "v2018_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_7")))]
use crate::Repo;
use glib::translate::*;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeMutableTree")]
pub struct MutableTree(Object<ffi::OstreeMutableTree, ffi::OstreeMutableTreeClass>);
match fn {
type_ => || ffi::ostree_mutable_tree_get_type(),
}
}
impl MutableTree {
#[doc(alias = "ostree_mutable_tree_new")]
pub fn new() -> MutableTree {
unsafe {
from_glib_full(ffi::ostree_mutable_tree_new())
}
}
#[cfg(any(feature = "v2018_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_7")))]
#[doc(alias = "ostree_mutable_tree_new_from_checksum")]
#[doc(alias = "new_from_checksum")]
pub fn from_checksum(repo: &Repo, contents_checksum: &str, metadata_checksum: &str) -> MutableTree {
unsafe {
from_glib_full(ffi::ostree_mutable_tree_new_from_checksum(repo.to_glib_none().0, contents_checksum.to_glib_none().0, metadata_checksum.to_glib_none().0))
}
}
#[cfg(any(feature = "v2021_5", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_5")))]
#[doc(alias = "ostree_mutable_tree_new_from_commit")]
#[doc(alias = "new_from_commit")]
pub fn from_commit(repo: &Repo, rev: &str) -> Result<MutableTree, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_mutable_tree_new_from_commit(repo.to_glib_none().0, rev.to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2018_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_7")))]
#[doc(alias = "ostree_mutable_tree_check_error")]
pub fn check_error(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_mutable_tree_check_error(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_mutable_tree_ensure_dir")]
pub fn ensure_dir(&self, name: &str) -> Result<MutableTree, glib::Error> {
unsafe {
let mut out_subdir = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_mutable_tree_ensure_dir(self.to_glib_none().0, name.to_glib_none().0, &mut out_subdir, &mut error);
if error.is_null() { Ok(from_glib_full(out_subdir)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_mutable_tree_ensure_parent_dirs")]
pub fn ensure_parent_dirs(&self, split_path: &[&str], metadata_checksum: &str) -> Result<MutableTree, glib::Error> {
unsafe {
let mut out_parent = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_mutable_tree_ensure_parent_dirs(self.to_glib_none().0, split_path.to_glib_none().0, metadata_checksum.to_glib_none().0, &mut out_parent, &mut error);
if error.is_null() { Ok(from_glib_full(out_parent)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2018_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_7")))]
#[doc(alias = "ostree_mutable_tree_fill_empty_from_dirtree")]
pub fn fill_empty_from_dirtree(&self, repo: &Repo, contents_checksum: &str, metadata_checksum: &str) -> bool {
unsafe {
from_glib(ffi::ostree_mutable_tree_fill_empty_from_dirtree(self.to_glib_none().0, repo.to_glib_none().0, contents_checksum.to_glib_none().0, metadata_checksum.to_glib_none().0))
}
}
#[doc(alias = "ostree_mutable_tree_get_contents_checksum")]
#[doc(alias = "get_contents_checksum")]
pub fn contents_checksum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_mutable_tree_get_contents_checksum(self.to_glib_none().0))
}
}
//#[doc(alias = "ostree_mutable_tree_get_files")]
//#[doc(alias = "get_files")]
//pub fn files(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 } {
// unsafe { TODO: call ffi:ostree_mutable_tree_get_files() }
//}
#[doc(alias = "ostree_mutable_tree_get_metadata_checksum")]
#[doc(alias = "get_metadata_checksum")]
pub fn metadata_checksum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_mutable_tree_get_metadata_checksum(self.to_glib_none().0))
}
}
//#[doc(alias = "ostree_mutable_tree_get_subdirs")]
//#[doc(alias = "get_subdirs")]
//pub fn subdirs(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 1, id: 44 } {
// unsafe { TODO: call ffi:ostree_mutable_tree_get_subdirs() }
//}
#[doc(alias = "ostree_mutable_tree_lookup")]
pub fn lookup(&self, name: &str) -> Result<(glib::GString, MutableTree), glib::Error> {
unsafe {
let mut out_file_checksum = ptr::null_mut();
let mut out_subdir = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_mutable_tree_lookup(self.to_glib_none().0, name.to_glib_none().0, &mut out_file_checksum, &mut out_subdir, &mut error);
if error.is_null() { Ok((from_glib_full(out_file_checksum), from_glib_full(out_subdir))) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2018_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_9")))]
#[doc(alias = "ostree_mutable_tree_remove")]
pub fn remove(&self, name: &str, allow_noent: bool) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_mutable_tree_remove(self.to_glib_none().0, name.to_glib_none().0, allow_noent.into_glib(), &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_mutable_tree_replace_file")]
pub fn replace_file(&self, name: &str, checksum: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_mutable_tree_replace_file(self.to_glib_none().0, name.to_glib_none().0, checksum.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_mutable_tree_set_contents_checksum")]
pub fn set_contents_checksum(&self, checksum: &str) {
unsafe {
ffi::ostree_mutable_tree_set_contents_checksum(self.to_glib_none().0, checksum.to_glib_none().0);
}
}
#[doc(alias = "ostree_mutable_tree_set_metadata_checksum")]
pub fn set_metadata_checksum(&self, checksum: &str) {
unsafe {
ffi::ostree_mutable_tree_set_metadata_checksum(self.to_glib_none().0, checksum.to_glib_none().0);
}
}
#[doc(alias = "ostree_mutable_tree_walk")]
pub fn walk(&self, split_path: &[&str], start: u32) -> Result<MutableTree, glib::Error> {
unsafe {
let mut out_subdir = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_mutable_tree_walk(self.to_glib_none().0, split_path.to_glib_none().0, start, &mut out_subdir, &mut error);
if error.is_null() { Ok(from_glib_full(out_subdir)) } else { Err(from_glib_full(error)) }
}
}
}
impl Default for MutableTree {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for MutableTree {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("MutableTree")
}
}

34
rust-bindings/src/auto/remote.rs generated Normal file
View File

@ -0,0 +1,34 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::translate::*;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Remote(Shared<ffi::OstreeRemote>);
match fn {
ref => |ptr| ffi::ostree_remote_ref(ptr),
unref => |ptr| ffi::ostree_remote_unref(ptr),
type_ => || ffi::ostree_remote_get_type(),
}
}
impl Remote {
#[doc(alias = "ostree_remote_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_remote_get_name(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_remote_get_url")]
#[doc(alias = "get_url")]
pub fn url(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_remote_get_url(self.to_glib_none().0))
}
}
}

1350
rust-bindings/src/auto/repo.rs generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,107 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::Repo;
use crate::RepoCommitFilterResult;
use crate::RepoCommitModifierFlags;
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
use crate::RepoDevInoCache;
use crate::SePolicy;
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
use glib::object::IsA;
use glib::translate::*;
use std::boxed::Box as Box_;
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
use std::ptr;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct RepoCommitModifier(Shared<ffi::OstreeRepoCommitModifier>);
match fn {
ref => |ptr| ffi::ostree_repo_commit_modifier_ref(ptr),
unref => |ptr| ffi::ostree_repo_commit_modifier_unref(ptr),
type_ => || ffi::ostree_repo_commit_modifier_get_type(),
}
}
impl RepoCommitModifier {
#[doc(alias = "ostree_repo_commit_modifier_new")]
pub fn new(flags: RepoCommitModifierFlags, commit_filter: Option<Box_<dyn Fn(&Repo, &str, &gio::FileInfo) -> RepoCommitFilterResult + 'static>>) -> RepoCommitModifier {
let commit_filter_data: Box_<Option<Box_<dyn Fn(&Repo, &str, &gio::FileInfo) -> RepoCommitFilterResult + 'static>>> = Box_::new(commit_filter);
unsafe extern "C" fn commit_filter_func(repo: *mut ffi::OstreeRepo, path: *const libc::c_char, file_info: *mut gio::ffi::GFileInfo, user_data: glib::ffi::gpointer) -> ffi::OstreeRepoCommitFilterResult {
let repo = from_glib_borrow(repo);
let path: Borrowed<glib::GString> = from_glib_borrow(path);
let file_info = from_glib_borrow(file_info);
let callback: &Option<Box_<dyn Fn(&Repo, &str, &gio::FileInfo) -> RepoCommitFilterResult + 'static>> = &*(user_data as *mut _);
let res = if let Some(ref callback) = *callback {
callback(&repo, path.as_str(), &file_info)
} else {
panic!("cannot get closure...")
};
res.into_glib()
}
let commit_filter = if commit_filter_data.is_some() { Some(commit_filter_func as _) } else { None };
unsafe extern "C" fn destroy_notify_func(data: glib::ffi::gpointer) {
let _callback: Box_<Option<Box_<dyn Fn(&Repo, &str, &gio::FileInfo) -> RepoCommitFilterResult + 'static>>> = Box_::from_raw(data as *mut _);
}
let destroy_call3 = Some(destroy_notify_func as _);
let super_callback0: Box_<Option<Box_<dyn Fn(&Repo, &str, &gio::FileInfo) -> RepoCommitFilterResult + 'static>>> = commit_filter_data;
unsafe {
from_glib_full(ffi::ostree_repo_commit_modifier_new(flags.into_glib(), commit_filter, Box_::into_raw(super_callback0) as *mut _, destroy_call3))
}
}
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
#[doc(alias = "ostree_repo_commit_modifier_set_devino_cache")]
pub fn set_devino_cache(&self, cache: &RepoDevInoCache) {
unsafe {
ffi::ostree_repo_commit_modifier_set_devino_cache(self.to_glib_none().0, cache.to_glib_none().0);
}
}
#[doc(alias = "ostree_repo_commit_modifier_set_sepolicy")]
pub fn set_sepolicy(&self, sepolicy: Option<&SePolicy>) {
unsafe {
ffi::ostree_repo_commit_modifier_set_sepolicy(self.to_glib_none().0, sepolicy.to_glib_none().0);
}
}
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
#[doc(alias = "ostree_repo_commit_modifier_set_sepolicy_from_commit")]
pub fn set_sepolicy_from_commit<P: IsA<gio::Cancellable>>(&self, repo: &Repo, rev: &str, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_repo_commit_modifier_set_sepolicy_from_commit(self.to_glib_none().0, repo.to_glib_none().0, rev.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_repo_commit_modifier_set_xattr_callback")]
pub fn set_xattr_callback<P: Fn(&Repo, &str, &gio::FileInfo) -> glib::Variant + 'static>(&self, callback: P) {
let callback_data: Box_<P> = Box_::new(callback);
unsafe extern "C" fn callback_func<P: Fn(&Repo, &str, &gio::FileInfo) -> glib::Variant + 'static>(repo: *mut ffi::OstreeRepo, path: *const libc::c_char, file_info: *mut gio::ffi::GFileInfo, user_data: glib::ffi::gpointer) -> *mut glib::ffi::GVariant {
let repo = from_glib_borrow(repo);
let path: Borrowed<glib::GString> = from_glib_borrow(path);
let file_info = from_glib_borrow(file_info);
let callback: &P = &*(user_data as *mut _);
let res = (*callback)(&repo, path.as_str(), &file_info);
res.to_glib_full()
}
let callback = Some(callback_func::<P> as _);
unsafe extern "C" fn destroy_func<P: Fn(&Repo, &str, &gio::FileInfo) -> glib::Variant + 'static>(data: glib::ffi::gpointer) {
let _callback: Box_<P> = Box_::from_raw(data as *mut _);
}
let destroy_call2 = Some(destroy_func::<P> as _);
let super_callback0: Box_<P> = callback_data;
unsafe {
ffi::ostree_repo_commit_modifier_set_xattr_callback(self.to_glib_none().0, callback, destroy_call2, Box_::into_raw(super_callback0) as *mut _);
}
}
}

View File

@ -0,0 +1,31 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::translate::*;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct RepoDevInoCache(Shared<ffi::OstreeRepoDevInoCache>);
match fn {
ref => |ptr| ffi::ostree_repo_devino_cache_ref(ptr),
unref => |ptr| ffi::ostree_repo_devino_cache_unref(ptr),
type_ => || ffi::ostree_repo_devino_cache_get_type(),
}
}
impl RepoDevInoCache {
#[doc(alias = "ostree_repo_devino_cache_new")]
pub fn new() -> RepoDevInoCache {
unsafe {
from_glib_full(ffi::ostree_repo_devino_cache_new())
}
}
}
impl Default for RepoDevInoCache {
fn default() -> Self {
Self::new()
}
}

127
rust-bindings/src/auto/repo_file.rs generated Normal file
View File

@ -0,0 +1,127 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::Repo;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::mem;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeRepoFile")]
pub struct RepoFile(Object<ffi::OstreeRepoFile, ffi::OstreeRepoFileClass>) @implements gio::File;
match fn {
type_ => || ffi::ostree_repo_file_get_type(),
}
}
impl RepoFile {
#[doc(alias = "ostree_repo_file_ensure_resolved")]
pub fn ensure_resolved(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_repo_file_ensure_resolved(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_repo_file_get_checksum")]
#[doc(alias = "get_checksum")]
pub fn checksum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_repo_file_get_checksum(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_get_repo")]
#[doc(alias = "get_repo")]
pub fn repo(&self) -> Option<Repo> {
unsafe {
from_glib_none(ffi::ostree_repo_file_get_repo(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_get_root")]
#[doc(alias = "get_root")]
pub fn root(&self) -> Option<RepoFile> {
unsafe {
from_glib_none(ffi::ostree_repo_file_get_root(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_get_xattrs")]
#[doc(alias = "get_xattrs")]
pub fn xattrs<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<glib::Variant, glib::Error> {
unsafe {
let mut out_xattrs = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_repo_file_get_xattrs(self.to_glib_none().0, &mut out_xattrs, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_xattrs)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_repo_file_tree_find_child")]
pub fn tree_find_child(&self, name: &str) -> (i32, bool, glib::Variant) {
unsafe {
let mut is_dir = mem::MaybeUninit::uninit();
let mut out_container = ptr::null_mut();
let ret = ffi::ostree_repo_file_tree_find_child(self.to_glib_none().0, name.to_glib_none().0, is_dir.as_mut_ptr(), &mut out_container);
let is_dir = is_dir.assume_init();
(ret, from_glib(is_dir), from_glib_full(out_container))
}
}
#[doc(alias = "ostree_repo_file_tree_get_contents")]
pub fn tree_get_contents(&self) -> Option<glib::Variant> {
unsafe {
from_glib_full(ffi::ostree_repo_file_tree_get_contents(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_tree_get_contents_checksum")]
pub fn tree_get_contents_checksum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_repo_file_tree_get_contents_checksum(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_tree_get_metadata")]
pub fn tree_get_metadata(&self) -> Option<glib::Variant> {
unsafe {
from_glib_full(ffi::ostree_repo_file_tree_get_metadata(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_tree_get_metadata_checksum")]
pub fn tree_get_metadata_checksum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_repo_file_tree_get_metadata_checksum(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_tree_query_child")]
pub fn tree_query_child<P: IsA<gio::Cancellable>>(&self, n: i32, attributes: &str, flags: gio::FileQueryInfoFlags, cancellable: Option<&P>) -> Result<gio::FileInfo, glib::Error> {
unsafe {
let mut out_info = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_repo_file_tree_query_child(self.to_glib_none().0, n, attributes.to_glib_none().0, flags.into_glib(), &mut out_info, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_info)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_repo_file_tree_set_metadata")]
pub fn tree_set_metadata(&self, checksum: &str, metadata: &glib::Variant) {
unsafe {
ffi::ostree_repo_file_tree_set_metadata(self.to_glib_none().0, checksum.to_glib_none().0, metadata.to_glib_none().0);
}
}
}
impl fmt::Display for RepoFile {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RepoFile")
}
}

32
rust-bindings/src/auto/repo_finder.rs generated Normal file
View File

@ -0,0 +1,32 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::RepoFinderResult;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeRepoFinder")]
pub struct RepoFinder(Interface<ffi::OstreeRepoFinder, ffi::OstreeRepoFinderInterface>);
match fn {
type_ => || ffi::ostree_repo_finder_get_type(),
}
}
impl RepoFinder {}
pub const NONE_REPO_FINDER: Option<&RepoFinder> = None;
pub trait RepoFinderExt: 'static {}
impl<O: IsA<RepoFinder>> RepoFinderExt for O {}
impl fmt::Display for RepoFinder {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RepoFinder")
}
}

View File

@ -0,0 +1,48 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::RepoFinder;
use glib::translate::*;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeRepoFinderAvahi")]
pub struct RepoFinderAvahi(Object<ffi::OstreeRepoFinderAvahi, ffi::OstreeRepoFinderAvahiClass>) @implements RepoFinder;
match fn {
type_ => || ffi::ostree_repo_finder_avahi_get_type(),
}
}
impl RepoFinderAvahi {
#[doc(alias = "ostree_repo_finder_avahi_new")]
pub fn new(context: Option<&glib::MainContext>) -> RepoFinderAvahi {
unsafe {
from_glib_full(ffi::ostree_repo_finder_avahi_new(context.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_finder_avahi_start")]
pub fn start(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_repo_finder_avahi_start(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_repo_finder_avahi_stop")]
pub fn stop(&self) {
unsafe {
ffi::ostree_repo_finder_avahi_stop(self.to_glib_none().0);
}
}
}
impl fmt::Display for RepoFinderAvahi {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RepoFinderAvahi")
}
}

View File

@ -0,0 +1,39 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::RepoFinder;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
#[doc(alias = "OstreeRepoFinderConfig")]
pub struct RepoFinderConfig(Object<ffi::OstreeRepoFinderConfig, ffi::OstreeRepoFinderConfigClass>) @implements RepoFinder;
match fn {
type_ => || ffi::ostree_repo_finder_config_get_type(),
}
}
impl RepoFinderConfig {
#[doc(alias = "ostree_repo_finder_config_new")]
pub fn new() -> RepoFinderConfig {
unsafe {
from_glib_full(ffi::ostree_repo_finder_config_new())
}
}
}
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
impl Default for RepoFinderConfig {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for RepoFinderConfig {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RepoFinderConfig")
}
}

View File

@ -0,0 +1,44 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::RepoFinder;
use glib::object::IsA;
use glib::object::ObjectType as ObjectType_;
use glib::translate::*;
use glib::StaticType;
use std::fmt;
glib::wrapper! {
#[doc(alias = "OstreeRepoFinderMount")]
pub struct RepoFinderMount(Object<ffi::OstreeRepoFinderMount, ffi::OstreeRepoFinderMountClass>) @implements RepoFinder;
match fn {
type_ => || ffi::ostree_repo_finder_mount_get_type(),
}
}
impl RepoFinderMount {
#[doc(alias = "ostree_repo_finder_mount_new")]
pub fn new<P: IsA<gio::VolumeMonitor>>(monitor: Option<&P>) -> RepoFinderMount {
unsafe {
from_glib_full(ffi::ostree_repo_finder_mount_new(monitor.map(|p| p.as_ref()).to_glib_none().0))
}
}
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub fn monitor(&self) -> Option<gio::VolumeMonitor> {
unsafe {
let mut value = glib::Value::from_type(<gio::VolumeMonitor as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(self.as_ptr() as *mut glib::gobject_ffi::GObject, b"monitor\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().expect("Return Value for property `monitor` getter")
}
}
}
impl fmt::Display for RepoFinderMount {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RepoFinderMount")
}
}

View File

@ -0,0 +1,46 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::RepoFinder;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
#[doc(alias = "OstreeRepoFinderOverride")]
pub struct RepoFinderOverride(Object<ffi::OstreeRepoFinderOverride, ffi::OstreeRepoFinderOverrideClass>) @implements RepoFinder;
match fn {
type_ => || ffi::ostree_repo_finder_override_get_type(),
}
}
impl RepoFinderOverride {
#[doc(alias = "ostree_repo_finder_override_new")]
pub fn new() -> RepoFinderOverride {
unsafe {
from_glib_full(ffi::ostree_repo_finder_override_new())
}
}
#[doc(alias = "ostree_repo_finder_override_add_uri")]
pub fn add_uri(&self, uri: &str) {
unsafe {
ffi::ostree_repo_finder_override_add_uri(self.to_glib_none().0, uri.to_glib_none().0);
}
}
}
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
impl Default for RepoFinderOverride {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for RepoFinderOverride {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RepoFinderOverride")
}
}

View File

@ -0,0 +1,54 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use std::cmp;
use glib::translate::*;
glib::wrapper! {
#[derive(Debug, Hash)]
pub struct RepoFinderResult(Boxed<ffi::OstreeRepoFinderResult>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::ostree_repo_finder_result_get_type(), ptr as *mut _) as *mut ffi::OstreeRepoFinderResult,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::ostree_repo_finder_result_get_type(), ptr as *mut _),
type_ => || ffi::ostree_repo_finder_result_get_type(),
}
}
impl RepoFinderResult {
//#[doc(alias = "ostree_repo_finder_result_new")]
//pub fn new<P: IsA<RepoFinder>>(remote: &Remote, finder: &P, priority: i32, ref_to_checksum: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 1, id: 0 }/TypeId { ns_id: 0, id: 28 }, ref_to_timestamp: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 1, id: 0 }/TypeId { ns_id: 0, id: 9 }, summary_last_modified: u64) -> RepoFinderResult {
// unsafe { TODO: call ffi:ostree_repo_finder_result_new() }
//}
#[doc(alias = "ostree_repo_finder_result_compare")]
fn compare(&self, b: &RepoFinderResult) -> i32 {
unsafe {
ffi::ostree_repo_finder_result_compare(self.to_glib_none().0, b.to_glib_none().0)
}
}
}
impl PartialEq for RepoFinderResult {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.compare(other) == 0
}
}
impl Eq for RepoFinderResult {}
impl PartialOrd for RepoFinderResult {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
self.compare(other).partial_cmp(&0)
}
}
impl Ord for RepoFinderResult {
#[inline]
fn cmp(&self, other: &Self) -> cmp::Ordering {
self.compare(other).cmp(&0)
}
}

126
rust-bindings/src/auto/se_policy.rs generated Normal file
View File

@ -0,0 +1,126 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::Repo;
use crate::SePolicyRestoreconFlags;
use glib::object::IsA;
use glib::object::ObjectType as ObjectType_;
use glib::translate::*;
use glib::StaticType;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeSePolicy")]
pub struct SePolicy(Object<ffi::OstreeSePolicy>);
match fn {
type_ => || ffi::ostree_sepolicy_get_type(),
}
}
impl SePolicy {
#[doc(alias = "ostree_sepolicy_new")]
pub fn new<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(path: &P, cancellable: Option<&Q>) -> Result<SePolicy, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_sepolicy_new(path.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2017_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_4")))]
#[doc(alias = "ostree_sepolicy_new_at")]
pub fn new_at<P: IsA<gio::Cancellable>>(rootfs_dfd: i32, cancellable: Option<&P>) -> Result<SePolicy, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_sepolicy_new_at(rootfs_dfd, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sepolicy_new_from_commit")]
#[doc(alias = "new_from_commit")]
pub fn from_commit<P: IsA<gio::Cancellable>>(repo: &Repo, rev: &str, cancellable: Option<&P>) -> Result<SePolicy, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_sepolicy_new_from_commit(repo.to_glib_none().0, rev.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2016_5", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_5")))]
#[doc(alias = "ostree_sepolicy_get_csum")]
#[doc(alias = "get_csum")]
pub fn csum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_sepolicy_get_csum(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sepolicy_get_label")]
#[doc(alias = "get_label")]
pub fn label<P: IsA<gio::Cancellable>>(&self, relpath: &str, unix_mode: u32, cancellable: Option<&P>) -> Result<glib::GString, glib::Error> {
unsafe {
let mut out_label = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sepolicy_get_label(self.to_glib_none().0, relpath.to_glib_none().0, unix_mode, &mut out_label, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_label)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sepolicy_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_sepolicy_get_name(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sepolicy_get_path")]
#[doc(alias = "get_path")]
pub fn path(&self) -> Option<gio::File> {
unsafe {
from_glib_none(ffi::ostree_sepolicy_get_path(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sepolicy_restorecon")]
pub fn restorecon<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(&self, path: &str, info: Option<&gio::FileInfo>, target: &P, flags: SePolicyRestoreconFlags, cancellable: Option<&Q>) -> Result<glib::GString, glib::Error> {
unsafe {
let mut out_new_label = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sepolicy_restorecon(self.to_glib_none().0, path.to_glib_none().0, info.to_glib_none().0, target.as_ref().to_glib_none().0, flags.into_glib(), &mut out_new_label, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_new_label)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sepolicy_setfscreatecon")]
pub fn setfscreatecon(&self, path: &str, mode: u32) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sepolicy_setfscreatecon(self.to_glib_none().0, path.to_glib_none().0, mode, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "rootfs-dfd")]
pub fn rootfs_dfd(&self) -> i32 {
unsafe {
let mut value = glib::Value::from_type(<i32 as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(self.as_ptr() as *mut glib::gobject_ffi::GObject, b"rootfs-dfd\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().expect("Return Value for property `rootfs-dfd` getter")
}
}
}
unsafe impl Send for SePolicy {}
impl fmt::Display for SePolicy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("SePolicy")
}
}

191
rust-bindings/src/auto/sign.rs generated Normal file
View File

@ -0,0 +1,191 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::Repo;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeSign")]
pub struct Sign(Interface<ffi::OstreeSign, ffi::OstreeSignInterface>);
match fn {
type_ => || ffi::ostree_sign_get_type(),
}
}
impl Sign {
#[doc(alias = "ostree_sign_get_all")]
#[doc(alias = "get_all")]
pub fn all() -> Vec<Sign> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::ostree_sign_get_all())
}
}
#[doc(alias = "ostree_sign_get_by_name")]
#[doc(alias = "get_by_name")]
pub fn by_name(name: &str) -> Result<Sign, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_sign_get_by_name(name.to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
}
pub const NONE_SIGN: Option<&Sign> = None;
pub trait SignExt: 'static {
#[doc(alias = "ostree_sign_add_pk")]
fn add_pk(&self, public_key: &glib::Variant) -> Result<(), glib::Error>;
#[doc(alias = "ostree_sign_clear_keys")]
fn clear_keys(&self) -> Result<(), glib::Error>;
#[doc(alias = "ostree_sign_commit")]
fn commit<P: IsA<gio::Cancellable>>(&self, repo: &Repo, commit_checksum: &str, cancellable: Option<&P>) -> Result<(), glib::Error>;
#[doc(alias = "ostree_sign_commit_verify")]
fn commit_verify<P: IsA<gio::Cancellable>>(&self, repo: &Repo, commit_checksum: &str, cancellable: Option<&P>) -> Result<Option<glib::GString>, glib::Error>;
#[doc(alias = "ostree_sign_data")]
fn data<P: IsA<gio::Cancellable>>(&self, data: &glib::Bytes, cancellable: Option<&P>) -> Result<glib::Bytes, glib::Error>;
#[doc(alias = "ostree_sign_data_verify")]
fn data_verify(&self, data: &glib::Bytes, signatures: &glib::Variant) -> Result<Option<glib::GString>, glib::Error>;
#[doc(alias = "ostree_sign_get_name")]
#[doc(alias = "get_name")]
fn name(&self) -> Option<glib::GString>;
#[doc(alias = "ostree_sign_load_pk")]
fn load_pk(&self, options: &glib::Variant) -> Result<(), glib::Error>;
#[doc(alias = "ostree_sign_metadata_format")]
fn metadata_format(&self) -> Option<glib::GString>;
#[doc(alias = "ostree_sign_metadata_key")]
fn metadata_key(&self) -> Option<glib::GString>;
#[doc(alias = "ostree_sign_set_pk")]
fn set_pk(&self, public_key: &glib::Variant) -> Result<(), glib::Error>;
#[doc(alias = "ostree_sign_set_sk")]
fn set_sk(&self, secret_key: &glib::Variant) -> Result<(), glib::Error>;
#[doc(alias = "ostree_sign_summary")]
fn summary<P: IsA<gio::Cancellable>>(&self, repo: &Repo, keys: &glib::Variant, cancellable: Option<&P>) -> Result<(), glib::Error>;
}
impl<O: IsA<Sign>> SignExt for O {
fn add_pk(&self, public_key: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_add_pk(self.as_ref().to_glib_none().0, public_key.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn clear_keys(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_clear_keys(self.as_ref().to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn commit<P: IsA<gio::Cancellable>>(&self, repo: &Repo, commit_checksum: &str, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_commit(self.as_ref().to_glib_none().0, repo.to_glib_none().0, commit_checksum.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn commit_verify<P: IsA<gio::Cancellable>>(&self, repo: &Repo, commit_checksum: &str, cancellable: Option<&P>) -> Result<Option<glib::GString>, glib::Error> {
unsafe {
let mut out_success_message = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_commit_verify(self.as_ref().to_glib_none().0, repo.to_glib_none().0, commit_checksum.to_glib_none().0, &mut out_success_message, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_success_message)) } else { Err(from_glib_full(error)) }
}
}
fn data<P: IsA<gio::Cancellable>>(&self, data: &glib::Bytes, cancellable: Option<&P>) -> Result<glib::Bytes, glib::Error> {
unsafe {
let mut signature = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_data(self.as_ref().to_glib_none().0, data.to_glib_none().0, &mut signature, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(signature)) } else { Err(from_glib_full(error)) }
}
}
fn data_verify(&self, data: &glib::Bytes, signatures: &glib::Variant) -> Result<Option<glib::GString>, glib::Error> {
unsafe {
let mut out_success_message = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_data_verify(self.as_ref().to_glib_none().0, data.to_glib_none().0, signatures.to_glib_none().0, &mut out_success_message, &mut error);
if error.is_null() { Ok(from_glib_full(out_success_message)) } else { Err(from_glib_full(error)) }
}
}
fn name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_sign_get_name(self.as_ref().to_glib_none().0))
}
}
fn load_pk(&self, options: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_load_pk(self.as_ref().to_glib_none().0, options.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn metadata_format(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_sign_metadata_format(self.as_ref().to_glib_none().0))
}
}
fn metadata_key(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_sign_metadata_key(self.as_ref().to_glib_none().0))
}
}
fn set_pk(&self, public_key: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_set_pk(self.as_ref().to_glib_none().0, public_key.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn set_sk(&self, secret_key: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_set_sk(self.as_ref().to_glib_none().0, secret_key.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn summary<P: IsA<gio::Cancellable>>(&self, repo: &Repo, keys: &glib::Variant, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_summary(self.as_ref().to_glib_none().0, repo.to_glib_none().0, keys.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
}
impl fmt::Display for Sign {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Sign")
}
}

509
rust-bindings/src/auto/sysroot.rs generated Normal file
View File

@ -0,0 +1,509 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::Deployment;
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
use crate::DeploymentUnlockedState;
#[cfg(any(feature = "v2017_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
use crate::Repo;
#[cfg(any(feature = "v2020_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_7")))]
use crate::SysrootDeployTreeOpts;
use crate::SysrootSimpleWriteDeploymentFlags;
#[cfg(any(feature = "v2017_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_4")))]
use crate::SysrootWriteDeploymentsOpts;
use glib::object::IsA;
#[cfg(any(feature = "v2017_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_10")))]
use glib::object::ObjectType as ObjectType_;
#[cfg(any(feature = "v2017_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_10")))]
use glib::signal::connect_raw;
#[cfg(any(feature = "v2017_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_10")))]
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem;
#[cfg(any(feature = "v2017_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_10")))]
use std::mem::transmute;
use std::pin::Pin;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeSysroot")]
pub struct Sysroot(Object<ffi::OstreeSysroot>);
match fn {
type_ => || ffi::ostree_sysroot_get_type(),
}
}
impl Sysroot {
#[doc(alias = "ostree_sysroot_new")]
pub fn new<P: IsA<gio::File>>(path: Option<&P>) -> Sysroot {
unsafe {
from_glib_full(ffi::ostree_sysroot_new(path.map(|p| p.as_ref()).to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_new_default")]
pub fn new_default() -> Sysroot {
unsafe {
from_glib_full(ffi::ostree_sysroot_new_default())
}
}
#[doc(alias = "ostree_sysroot_cleanup")]
pub fn cleanup<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_cleanup(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
//#[cfg(any(feature = "v2018_6", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
//#[doc(alias = "ostree_sysroot_cleanup_prune_repo")]
//pub fn cleanup_prune_repo<P: IsA<gio::Cancellable>>(&self, options: /*Ignored*/&mut RepoPruneOptions, cancellable: Option<&P>) -> Result<(i32, i32, u64), glib::Error> {
// unsafe { TODO: call ffi:ostree_sysroot_cleanup_prune_repo() }
//}
#[cfg(any(feature = "v2018_5", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_5")))]
#[doc(alias = "ostree_sysroot_deploy_tree")]
pub fn deploy_tree<P: IsA<gio::Cancellable>>(&self, osname: Option<&str>, revision: &str, origin: Option<&glib::KeyFile>, provided_merge_deployment: Option<&Deployment>, override_kernel_argv: &[&str], cancellable: Option<&P>) -> Result<Deployment, glib::Error> {
unsafe {
let mut out_new_deployment = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_deploy_tree(self.to_glib_none().0, osname.to_glib_none().0, revision.to_glib_none().0, origin.to_glib_none().0, provided_merge_deployment.to_glib_none().0, override_kernel_argv.to_glib_none().0, &mut out_new_deployment, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_new_deployment)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2020_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_7")))]
#[doc(alias = "ostree_sysroot_deploy_tree_with_options")]
pub fn deploy_tree_with_options<P: IsA<gio::Cancellable>>(&self, osname: Option<&str>, revision: &str, origin: Option<&glib::KeyFile>, provided_merge_deployment: Option<&Deployment>, opts: Option<&SysrootDeployTreeOpts>, cancellable: Option<&P>) -> Result<Deployment, glib::Error> {
unsafe {
let mut out_new_deployment = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_deploy_tree_with_options(self.to_glib_none().0, osname.to_glib_none().0, revision.to_glib_none().0, origin.to_glib_none().0, provided_merge_deployment.to_glib_none().0, mut_override(opts.to_glib_none().0), &mut out_new_deployment, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_new_deployment)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_deployment_set_kargs")]
pub fn deployment_set_kargs<P: IsA<gio::Cancellable>>(&self, deployment: &Deployment, new_kargs: &[&str], cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_deployment_set_kargs(self.to_glib_none().0, deployment.to_glib_none().0, new_kargs.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_deployment_set_mutable")]
pub fn deployment_set_mutable<P: IsA<gio::Cancellable>>(&self, deployment: &Deployment, is_mutable: bool, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_deployment_set_mutable(self.to_glib_none().0, deployment.to_glib_none().0, is_mutable.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2018_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_3")))]
#[doc(alias = "ostree_sysroot_deployment_set_pinned")]
pub fn deployment_set_pinned(&self, deployment: &Deployment, is_pinned: bool) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_deployment_set_pinned(self.to_glib_none().0, deployment.to_glib_none().0, is_pinned.into_glib(), &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
#[doc(alias = "ostree_sysroot_deployment_unlock")]
pub fn deployment_unlock<P: IsA<gio::Cancellable>>(&self, deployment: &Deployment, unlocked_state: DeploymentUnlockedState, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_deployment_unlock(self.to_glib_none().0, deployment.to_glib_none().0, unlocked_state.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_ensure_initialized")]
pub fn ensure_initialized<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_ensure_initialized(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_get_booted_deployment")]
#[doc(alias = "get_booted_deployment")]
pub fn booted_deployment(&self) -> Option<Deployment> {
unsafe {
from_glib_none(ffi::ostree_sysroot_get_booted_deployment(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_get_bootversion")]
#[doc(alias = "get_bootversion")]
pub fn bootversion(&self) -> i32 {
unsafe {
ffi::ostree_sysroot_get_bootversion(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_sysroot_get_deployment_directory")]
#[doc(alias = "get_deployment_directory")]
pub fn deployment_directory(&self, deployment: &Deployment) -> Option<gio::File> {
unsafe {
from_glib_full(ffi::ostree_sysroot_get_deployment_directory(self.to_glib_none().0, deployment.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_get_deployment_dirpath")]
#[doc(alias = "get_deployment_dirpath")]
pub fn deployment_dirpath(&self, deployment: &Deployment) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_sysroot_get_deployment_dirpath(self.to_glib_none().0, deployment.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_get_deployments")]
#[doc(alias = "get_deployments")]
pub fn deployments(&self) -> Vec<Deployment> {
unsafe {
FromGlibPtrContainer::from_glib_container(ffi::ostree_sysroot_get_deployments(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_get_fd")]
#[doc(alias = "get_fd")]
pub fn fd(&self) -> i32 {
unsafe {
ffi::ostree_sysroot_get_fd(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_sysroot_get_merge_deployment")]
#[doc(alias = "get_merge_deployment")]
pub fn merge_deployment(&self, osname: Option<&str>) -> Option<Deployment> {
unsafe {
from_glib_full(ffi::ostree_sysroot_get_merge_deployment(self.to_glib_none().0, osname.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_get_path")]
#[doc(alias = "get_path")]
pub fn path(&self) -> Option<gio::File> {
unsafe {
from_glib_none(ffi::ostree_sysroot_get_path(self.to_glib_none().0))
}
}
#[cfg(any(feature = "v2018_5", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_5")))]
#[doc(alias = "ostree_sysroot_get_staged_deployment")]
#[doc(alias = "get_staged_deployment")]
pub fn staged_deployment(&self) -> Option<Deployment> {
unsafe {
from_glib_none(ffi::ostree_sysroot_get_staged_deployment(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_get_subbootversion")]
#[doc(alias = "get_subbootversion")]
pub fn subbootversion(&self) -> i32 {
unsafe {
ffi::ostree_sysroot_get_subbootversion(self.to_glib_none().0)
}
}
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
#[doc(alias = "ostree_sysroot_init_osname")]
pub fn init_osname<P: IsA<gio::Cancellable>>(&self, osname: &str, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_init_osname(self.to_glib_none().0, osname.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
#[doc(alias = "ostree_sysroot_initialize")]
pub fn initialize(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_initialize(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
#[doc(alias = "ostree_sysroot_is_booted")]
pub fn is_booted(&self) -> bool {
unsafe {
from_glib(ffi::ostree_sysroot_is_booted(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_load")]
pub fn load<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_load(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
#[doc(alias = "ostree_sysroot_load_if_changed")]
pub fn load_if_changed<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<bool, glib::Error> {
unsafe {
let mut out_changed = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_load_if_changed(self.to_glib_none().0, out_changed.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
let out_changed = out_changed.assume_init();
if error.is_null() { Ok(from_glib(out_changed)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_lock")]
pub fn lock(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_lock(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_lock_async")]
pub fn lock_async<P: IsA<gio::Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>(&self, cancellable: Option<&P>, callback: Q) {
let user_data: Box_<Q> = Box_::new(callback);
unsafe extern "C" fn lock_async_trampoline<Q: FnOnce(Result<(), glib::Error>) + Send + 'static>(_source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer) {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_lock_finish(_source_object as *mut _, res, &mut error);
let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) };
let callback: Box_<Q> = Box_::from_raw(user_data as *mut _);
callback(result);
}
let callback = lock_async_trampoline::<Q>;
unsafe {
ffi::ostree_sysroot_lock_async(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _);
}
}
pub fn lock_async_future(&self) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
obj.lock_async(
Some(cancellable),
move |res| {
send.resolve(res);
},
);
}))
}
#[doc(alias = "ostree_sysroot_origin_new_from_refspec")]
pub fn origin_new_from_refspec(&self, refspec: &str) -> Option<glib::KeyFile> {
unsafe {
from_glib_full(ffi::ostree_sysroot_origin_new_from_refspec(self.to_glib_none().0, refspec.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_prepare_cleanup")]
pub fn prepare_cleanup<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_prepare_cleanup(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2017_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
#[doc(alias = "ostree_sysroot_query_deployments_for")]
pub fn query_deployments_for(&self, osname: Option<&str>) -> (Option<Deployment>, Option<Deployment>) {
unsafe {
let mut out_pending = ptr::null_mut();
let mut out_rollback = ptr::null_mut();
ffi::ostree_sysroot_query_deployments_for(self.to_glib_none().0, osname.to_glib_none().0, &mut out_pending, &mut out_rollback);
(from_glib_full(out_pending), from_glib_full(out_rollback))
}
}
#[cfg(any(feature = "v2017_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
#[doc(alias = "ostree_sysroot_repo")]
pub fn repo(&self) -> Option<Repo> {
unsafe {
from_glib_none(ffi::ostree_sysroot_repo(self.to_glib_none().0))
}
}
#[cfg(any(feature = "v2021_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_1")))]
#[doc(alias = "ostree_sysroot_require_booted_deployment")]
pub fn require_booted_deployment(&self) -> Result<Deployment, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_sysroot_require_booted_deployment(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_none(ret)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
#[doc(alias = "ostree_sysroot_set_mount_namespace_in_use")]
pub fn set_mount_namespace_in_use(&self) {
unsafe {
ffi::ostree_sysroot_set_mount_namespace_in_use(self.to_glib_none().0);
}
}
#[doc(alias = "ostree_sysroot_simple_write_deployment")]
pub fn simple_write_deployment<P: IsA<gio::Cancellable>>(&self, osname: Option<&str>, new_deployment: &Deployment, merge_deployment: Option<&Deployment>, flags: SysrootSimpleWriteDeploymentFlags, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_simple_write_deployment(self.to_glib_none().0, osname.to_glib_none().0, new_deployment.to_glib_none().0, merge_deployment.to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2020_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_7")))]
#[doc(alias = "ostree_sysroot_stage_overlay_initrd")]
pub fn stage_overlay_initrd<P: IsA<gio::Cancellable>>(&self, fd: i32, cancellable: Option<&P>) -> Result<glib::GString, glib::Error> {
unsafe {
let mut out_checksum = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_stage_overlay_initrd(self.to_glib_none().0, fd, &mut out_checksum, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_checksum)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2018_5", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_5")))]
#[doc(alias = "ostree_sysroot_stage_tree")]
pub fn stage_tree<P: IsA<gio::Cancellable>>(&self, osname: Option<&str>, revision: &str, origin: Option<&glib::KeyFile>, merge_deployment: Option<&Deployment>, override_kernel_argv: &[&str], cancellable: Option<&P>) -> Result<Deployment, glib::Error> {
unsafe {
let mut out_new_deployment = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_stage_tree(self.to_glib_none().0, osname.to_glib_none().0, revision.to_glib_none().0, origin.to_glib_none().0, merge_deployment.to_glib_none().0, override_kernel_argv.to_glib_none().0, &mut out_new_deployment, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_new_deployment)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2020_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_7")))]
#[doc(alias = "ostree_sysroot_stage_tree_with_options")]
pub fn stage_tree_with_options<P: IsA<gio::Cancellable>>(&self, osname: Option<&str>, revision: &str, origin: Option<&glib::KeyFile>, merge_deployment: Option<&Deployment>, opts: &SysrootDeployTreeOpts, cancellable: Option<&P>) -> Result<Deployment, glib::Error> {
unsafe {
let mut out_new_deployment = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_stage_tree_with_options(self.to_glib_none().0, osname.to_glib_none().0, revision.to_glib_none().0, origin.to_glib_none().0, merge_deployment.to_glib_none().0, mut_override(opts.to_glib_none().0), &mut out_new_deployment, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_new_deployment)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_try_lock")]
pub fn try_lock(&self) -> Result<bool, glib::Error> {
unsafe {
let mut out_acquired = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_try_lock(self.to_glib_none().0, out_acquired.as_mut_ptr(), &mut error);
let out_acquired = out_acquired.assume_init();
if error.is_null() { Ok(from_glib(out_acquired)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_unload")]
pub fn unload(&self) {
unsafe {
ffi::ostree_sysroot_unload(self.to_glib_none().0);
}
}
#[doc(alias = "ostree_sysroot_unlock")]
pub fn unlock(&self) {
unsafe {
ffi::ostree_sysroot_unlock(self.to_glib_none().0);
}
}
#[doc(alias = "ostree_sysroot_write_deployments")]
pub fn write_deployments<P: IsA<gio::Cancellable>>(&self, new_deployments: &[Deployment], cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_write_deployments(self.to_glib_none().0, new_deployments.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2017_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_4")))]
#[doc(alias = "ostree_sysroot_write_deployments_with_options")]
pub fn write_deployments_with_options<P: IsA<gio::Cancellable>>(&self, new_deployments: &[Deployment], opts: &SysrootWriteDeploymentsOpts, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_write_deployments_with_options(self.to_glib_none().0, new_deployments.to_glib_none().0, mut_override(opts.to_glib_none().0), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_write_origin_file")]
pub fn write_origin_file<P: IsA<gio::Cancellable>>(&self, deployment: &Deployment, new_origin: Option<&glib::KeyFile>, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_write_origin_file(self.to_glib_none().0, deployment.to_glib_none().0, new_origin.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_get_deployment_origin_path")]
#[doc(alias = "get_deployment_origin_path")]
pub fn deployment_origin_path<P: IsA<gio::File>>(deployment_path: &P) -> Option<gio::File> {
unsafe {
from_glib_full(ffi::ostree_sysroot_get_deployment_origin_path(deployment_path.as_ref().to_glib_none().0))
}
}
#[cfg(any(feature = "v2017_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_10")))]
#[doc(alias = "journal-msg")]
pub fn connect_journal_msg<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn journal_msg_trampoline<F: Fn(&Sysroot, &str) + 'static>(this: *mut ffi::OstreeSysroot, msg: *mut libc::c_char, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), &glib::GString::from_glib_borrow(msg))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"journal-msg\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(journal_msg_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
}
impl fmt::Display for Sysroot {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Sysroot")
}
}

159
rust-bindings/src/auto/sysroot_upgrader.rs generated Normal file
View File

@ -0,0 +1,159 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::AsyncProgress;
use crate::Repo;
use crate::RepoPullFlags;
use crate::Sysroot;
use crate::SysrootUpgraderFlags;
use crate::SysrootUpgraderPullFlags;
use glib::object::IsA;
use glib::object::ObjectType as ObjectType_;
use glib::translate::*;
use glib::StaticType;
use std::fmt;
use std::mem;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeSysrootUpgrader")]
pub struct SysrootUpgrader(Object<ffi::OstreeSysrootUpgrader>);
match fn {
type_ => || ffi::ostree_sysroot_upgrader_get_type(),
}
}
impl SysrootUpgrader {
#[doc(alias = "ostree_sysroot_upgrader_new")]
pub fn new<P: IsA<gio::Cancellable>>(sysroot: &Sysroot, cancellable: Option<&P>) -> Result<SysrootUpgrader, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_sysroot_upgrader_new(sysroot.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_upgrader_new_for_os")]
#[doc(alias = "new_for_os")]
pub fn for_os<P: IsA<gio::Cancellable>>(sysroot: &Sysroot, osname: Option<&str>, cancellable: Option<&P>) -> Result<SysrootUpgrader, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_sysroot_upgrader_new_for_os(sysroot.to_glib_none().0, osname.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_upgrader_new_for_os_with_flags")]
#[doc(alias = "new_for_os_with_flags")]
pub fn for_os_with_flags<P: IsA<gio::Cancellable>>(sysroot: &Sysroot, osname: Option<&str>, flags: SysrootUpgraderFlags, cancellable: Option<&P>) -> Result<SysrootUpgrader, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_sysroot_upgrader_new_for_os_with_flags(sysroot.to_glib_none().0, osname.to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_upgrader_deploy")]
pub fn deploy<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_upgrader_deploy(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_upgrader_dup_origin")]
pub fn dup_origin(&self) -> Option<glib::KeyFile> {
unsafe {
from_glib_full(ffi::ostree_sysroot_upgrader_dup_origin(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_upgrader_get_origin")]
#[doc(alias = "get_origin")]
pub fn origin(&self) -> Option<glib::KeyFile> {
unsafe {
from_glib_none(ffi::ostree_sysroot_upgrader_get_origin(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_upgrader_get_origin_description")]
#[doc(alias = "get_origin_description")]
pub fn origin_description(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_sysroot_upgrader_get_origin_description(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_upgrader_pull")]
pub fn pull<P: IsA<gio::Cancellable>>(&self, flags: RepoPullFlags, upgrader_flags: SysrootUpgraderPullFlags, progress: Option<&AsyncProgress>, cancellable: Option<&P>) -> Result<bool, glib::Error> {
unsafe {
let mut out_changed = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_upgrader_pull(self.to_glib_none().0, flags.into_glib(), upgrader_flags.into_glib(), progress.to_glib_none().0, out_changed.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
let out_changed = out_changed.assume_init();
if error.is_null() { Ok(from_glib(out_changed)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_upgrader_pull_one_dir")]
pub fn pull_one_dir<P: IsA<gio::Cancellable>>(&self, dir_to_pull: &str, flags: RepoPullFlags, upgrader_flags: SysrootUpgraderPullFlags, progress: Option<&AsyncProgress>, cancellable: Option<&P>) -> Result<bool, glib::Error> {
unsafe {
let mut out_changed = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_upgrader_pull_one_dir(self.to_glib_none().0, dir_to_pull.to_glib_none().0, flags.into_glib(), upgrader_flags.into_glib(), progress.to_glib_none().0, out_changed.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
let out_changed = out_changed.assume_init();
if error.is_null() { Ok(from_glib(out_changed)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_upgrader_set_origin")]
pub fn set_origin<P: IsA<gio::Cancellable>>(&self, origin: Option<&glib::KeyFile>, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_upgrader_set_origin(self.to_glib_none().0, origin.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
pub fn flags(&self) -> SysrootUpgraderFlags {
unsafe {
let mut value = glib::Value::from_type(<SysrootUpgraderFlags as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(self.as_ptr() as *mut glib::gobject_ffi::GObject, b"flags\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().expect("Return Value for property `flags` getter")
}
}
pub fn osname(&self) -> Option<glib::GString> {
unsafe {
let mut value = glib::Value::from_type(<glib::GString as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(self.as_ptr() as *mut glib::gobject_ffi::GObject, b"osname\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().expect("Return Value for property `osname` getter")
}
}
pub fn sysroot(&self) -> Option<Sysroot> {
unsafe {
let mut value = glib::Value::from_type(<Sysroot as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(self.as_ptr() as *mut glib::gobject_ffi::GObject, b"sysroot\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().expect("Return Value for property `sysroot` getter")
}
}
#[doc(alias = "ostree_sysroot_upgrader_check_timestamps")]
pub fn check_timestamps(repo: &Repo, from_rev: &str, to_rev: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_upgrader_check_timestamps(repo.to_glib_none().0, from_rev.to_glib_none().0, to_rev.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
}
impl fmt::Display for SysrootUpgrader {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("SysrootUpgrader")
}
}

2
rust-bindings/src/auto/versions.txt generated Normal file
View File

@ -0,0 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ e8f82cf6)
from gir-files

View File

@ -0,0 +1,245 @@
use glib::ffi::{g_free, g_malloc0, gpointer};
use glib::translate::{FromGlibPtrFull, FromGlibPtrNone};
use once_cell::sync::OnceCell;
use std::ptr::copy_nonoverlapping;
const BYTES_LEN: usize = ffi::OSTREE_SHA256_DIGEST_LEN as usize;
static BASE64_CONFIG: OnceCell<radix64::CustomConfig> = OnceCell::new();
fn base64_config() -> &'static radix64::CustomConfig {
BASE64_CONFIG.get_or_init(|| {
radix64::configs::CustomConfigBuilder::with_alphabet(
// modified base64 alphabet used by ostree (uses _ instead of /)
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_",
)
.no_padding()
.build()
.unwrap()
})
}
/// Error returned from parsing a checksum.
#[derive(Debug, thiserror::Error)]
pub enum ChecksumError {
/// Invalid hex checksum string.
#[error("invalid hex checksum string")]
InvalidHexString,
/// Invalid base64 checksum string
#[error("invalid base64 checksum string")]
InvalidBase64String,
}
/// A binary SHA256 checksum.
#[derive(Debug)]
pub struct Checksum {
bytes: *mut [u8; BYTES_LEN],
}
// Safety: just a pointer to some memory owned by the type itself.
unsafe impl Send for Checksum {}
impl Checksum {
/// Create a `Checksum` from a byte array.
///
/// This copies the array.
pub fn from_bytes(bytes: &[u8; BYTES_LEN]) -> Checksum {
let mut checksum = Checksum::zeroed();
checksum.as_mut().copy_from_slice(bytes);
checksum
}
/// Create a `Checksum` from a hexadecimal SHA256 string.
pub fn from_hex(hex_checksum: &str) -> Result<Checksum, ChecksumError> {
let mut checksum = Checksum::zeroed();
match hex::decode_to_slice(hex_checksum, checksum.as_mut()) {
Ok(_) => Ok(checksum),
Err(_) => Err(ChecksumError::InvalidHexString),
}
}
/// Create a `Checksum` from a base64-encoded String.
pub fn from_base64(b64_checksum: &str) -> Result<Checksum, ChecksumError> {
let mut checksum = Checksum::zeroed();
match base64_config().decode_slice(b64_checksum, checksum.as_mut()) {
Ok(BYTES_LEN) => Ok(checksum),
Ok(_) => Err(ChecksumError::InvalidBase64String),
Err(_) => Err(ChecksumError::InvalidBase64String),
}
}
/// Convert checksum to hex-encoded string.
pub fn to_hex(&self) -> String {
hex::encode(self.as_slice())
}
/// Convert checksum to base64 string.
pub fn to_base64(&self) -> String {
base64_config().encode(self.as_slice())
}
/// Create a `Checksum` value, taking ownership of the given memory location.
///
/// # Safety
/// `bytes` must point to an initialized 32-byte memory location that is freeable with
/// `g_free` (this is e.g. the case if the memory was allocated with `g_malloc`). The returned
/// value takes ownership of the memory and frees it on drop.
unsafe fn new(bytes: *mut [u8; BYTES_LEN]) -> Checksum {
assert!(!bytes.is_null());
Checksum { bytes }
}
/// Create a `Checksum` value initialized to 0.
fn zeroed() -> Checksum {
let bytes = unsafe { g_malloc0(BYTES_LEN) as *mut [u8; BYTES_LEN] };
Checksum { bytes }
}
/// Get a shared reference to the inner array.
fn as_slice(&self) -> &[u8; BYTES_LEN] {
unsafe { &(*self.bytes) }
}
/// Get a mutable reference to the inner array.
fn as_mut(&mut self) -> &mut [u8; BYTES_LEN] {
unsafe { &mut (*self.bytes) }
}
}
impl Drop for Checksum {
fn drop(&mut self) {
unsafe {
g_free(self.bytes as gpointer);
}
}
}
impl Clone for Checksum {
fn clone(&self) -> Self {
unsafe { Checksum::from_glib_none(self.bytes) }
}
}
impl PartialEq for Checksum {
fn eq(&self, other: &Self) -> bool {
unsafe {
let ret =
ffi::ostree_cmp_checksum_bytes(self.bytes as *const u8, other.bytes as *const u8);
ret == 0
}
}
}
impl Eq for Checksum {}
impl std::fmt::Display for Checksum {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.to_hex())
}
}
impl FromGlibPtrFull<*mut [u8; BYTES_LEN]> for Checksum {
unsafe fn from_glib_full(ptr: *mut [u8; BYTES_LEN]) -> Self {
Checksum::new(ptr)
}
}
impl FromGlibPtrFull<*mut [*mut u8; BYTES_LEN]> for Checksum {
unsafe fn from_glib_full(ptr: *mut [*mut u8; BYTES_LEN]) -> Self {
Checksum::new(ptr as *mut u8 as *mut [u8; BYTES_LEN])
}
}
impl FromGlibPtrFull<*mut u8> for Checksum {
unsafe fn from_glib_full(ptr: *mut u8) -> Self {
Checksum::new(ptr as *mut [u8; BYTES_LEN])
}
}
impl FromGlibPtrNone<*mut [u8; BYTES_LEN]> for Checksum {
unsafe fn from_glib_none(ptr: *mut [u8; BYTES_LEN]) -> Self {
let checksum = Checksum::zeroed();
// copy one array of BYTES_LEN elements
copy_nonoverlapping(ptr, checksum.bytes, 1);
checksum
}
}
#[cfg(test)]
mod tests {
use super::*;
use glib::ffi::g_malloc0;
use glib::translate::from_glib_full;
const CHECKSUM_BYTES: &[u8; BYTES_LEN] = b"\xbf\x87S\x06x>\xfd\xc5\xbc\xab7\xea\x10\xb6\xcaN\x9bj\xea\x8b\x94X\r\x0c\xa9J\xf1 V\\\x0e\x8a";
const CHECKSUM_HEX: &str = "bf875306783efdc5bcab37ea10b6ca4e9b6aea8b94580d0ca94af120565c0e8a";
const CHECKSUM_BASE64: &str = "v4dTBng+_cW8qzfqELbKTptq6ouUWA0MqUrxIFZcDoo";
#[test]
fn should_create_checksum_from_bytes_taking_ownership() {
let bytes = unsafe { g_malloc0(BYTES_LEN) } as *mut u8;
let checksum: Checksum = unsafe { from_glib_full(bytes) };
assert_eq!(checksum.to_string(), "00".repeat(BYTES_LEN));
}
#[test]
fn should_create_checksum_from_bytes() {
let checksum = Checksum::from_bytes(CHECKSUM_BYTES);
assert_eq!(checksum.to_hex(), CHECKSUM_HEX);
}
#[test]
fn should_parse_checksum_string_to_bytes() {
let csum = Checksum::from_hex(CHECKSUM_HEX).unwrap();
assert_eq!(csum.to_string(), CHECKSUM_HEX);
}
#[test]
fn should_fail_for_too_short_hex_string() {
let result = Checksum::from_hex(&"FF".repeat(31));
assert!(result.is_err());
}
#[test]
fn should_convert_checksum_to_base64() {
let csum = Checksum::from_hex(CHECKSUM_HEX).unwrap();
assert_eq!(csum.to_base64(), CHECKSUM_BASE64);
}
#[test]
fn should_convert_base64_string_to_checksum() {
let csum = Checksum::from_base64(CHECKSUM_BASE64).unwrap();
assert_eq!(csum.to_base64(), CHECKSUM_BASE64);
assert_eq!(csum.to_string(), CHECKSUM_HEX);
}
#[test]
fn should_fail_for_too_short_b64_string() {
let result = Checksum::from_base64("abcdefghi");
assert!(result.is_err());
}
#[test]
fn should_fail_for_invalid_base64_string() {
let result = Checksum::from_base64(&"\n".repeat(43));
assert!(result.is_err());
}
#[test]
fn should_compare_checksums() {
let csum = Checksum::from_hex(CHECKSUM_HEX).unwrap();
assert_eq!(csum, csum);
let csum2 = Checksum::from_hex(CHECKSUM_HEX).unwrap();
assert_eq!(csum2, csum);
}
#[test]
fn should_clone_value() {
let csum = Checksum::from_hex(CHECKSUM_HEX).unwrap();
let csum2 = csum.clone();
assert_eq!(csum2, csum);
let csum3 = csum2.clone();
assert_eq!(csum3, csum);
assert_eq!(csum3, csum2);
}
}

View File

@ -0,0 +1,78 @@
use crate::CollectionRef;
use glib::translate::ToGlibPtr;
use std::ffi::CStr;
trait AsNonnullPtr
where
Self: Sized,
{
fn as_nonnull_ptr(&self) -> Option<Self>;
}
impl<T> AsNonnullPtr for *mut T {
fn as_nonnull_ptr(&self) -> Option<Self> {
if self.is_null() {
None
} else {
Some(*self)
}
}
}
impl CollectionRef {
/// Get the collection ID from this `CollectionRef`.
///
/// # Returns
/// Since the value may not be valid UTF-8, `&CStr` is returned. You can safely turn it into a
/// `&str` using the `as_str` method.
///
/// If no collection ID was set in the `CollectionRef`, `None` is returned.
pub fn collection_id(&self) -> Option<&CStr> {
let inner = self.to_glib_none();
unsafe {
(*inner.0)
.collection_id
.as_nonnull_ptr()
.map(|ptr| CStr::from_ptr(ptr))
}
}
/// Get the ref name from this `CollectionRef`.
///
/// # Returns
/// Since the value may not be valid UTF-8, `&CStr` is returned. You can safely turn it into a
/// `&str` using the `as_str` method.
pub fn ref_name(&self) -> &CStr {
let inner = self.to_glib_none();
unsafe { CStr::from_ptr((*inner.0).ref_name) }
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn should_get_collection_id() {
let collection_ref = CollectionRef::new(Some("collection.id"), "ref").unwrap();
let id = collection_ref.collection_id().unwrap().to_str().unwrap();
assert_eq!(id, "collection.id");
}
#[test]
fn should_get_none_collection_id() {
let collection_ref = CollectionRef::new(None, "ref").unwrap();
let id = collection_ref.collection_id();
assert_eq!(id, None);
}
#[test]
fn should_get_ref_name() {
let collection_ref = CollectionRef::new(Some("collection.id"), "ref-name").unwrap();
let ref_name = collection_ref.ref_name().to_str().unwrap();
assert_eq!(ref_name, "ref-name");
}
}

View File

@ -0,0 +1,48 @@
use crate::{auto::CommitSizesEntry, auto::ObjectType};
use glib::{
translate::{FromGlib, FromGlibPtrNone, ToGlibPtr},
GString,
};
impl CommitSizesEntry {
/// Object checksum as hex string.
pub fn checksum(&self) -> GString {
let underlying = self.to_glib_none();
unsafe { GString::from_glib_none((*underlying.0).checksum) }
}
/// The object type.
pub fn objtype(&self) -> ObjectType {
let underlying = self.to_glib_none();
unsafe { ObjectType::from_glib((*underlying.0).objtype) }
}
/// Unpacked object size.
pub fn unpacked(&self) -> u64 {
let underlying = self.to_glib_none();
unsafe { (*underlying.0).unpacked }
}
/// Compressed object size.
pub fn archived(&self) -> u64 {
let underlying = self.to_glib_none();
unsafe { (*underlying.0).archived }
}
}
#[cfg(test)]
mod tests {
use super::*;
const CHECKSUM_STRING: &str =
"bf875306783efdc5bcab37ea10b6ca4e9b6aea8b94580d0ca94af120565c0e8a";
#[test]
fn should_get_values_from_commit_sizes_entry() {
let entry = CommitSizesEntry::new(CHECKSUM_STRING, ObjectType::Commit, 15, 16).unwrap();
assert_eq!(entry.checksum(), CHECKSUM_STRING);
assert_eq!(entry.objtype(), ObjectType::Commit);
assert_eq!(entry.unpacked(), 15);
assert_eq!(entry.archived(), 16);
}
}

View File

@ -0,0 +1,3 @@
/// Metadata key corresponding to the Docker/OCI `CMD` verb.
/// <https://github.com/opencontainers/image-spec/blob/main/config.md>
pub const COMMIT_META_CONTAINER_CMD: &str = "ostree.container-cmd";

48
rust-bindings/src/core.rs Normal file
View File

@ -0,0 +1,48 @@
//! Hand written bindings for ostree-core.h
use glib::VariantDict;
/// The type of a commit object: `(a{sv}aya(say)sstayay)`
pub type CommitVariantType = (
VariantDict,
Vec<u8>,
Vec<(String, Vec<u8>)>,
String,
String,
u64,
Vec<u8>,
Vec<u8>,
);
/// The type of a dirtree object: `(a(say)a(sayay))`
pub type TreeVariantType = (Vec<(String, Vec<u8>)>, Vec<(String, Vec<u8>, Vec<u8>)>);
/// The type of a directory metadata object: `(uuua(ayay))`
pub type DirmetaVariantType = (u32, u32, u32, Vec<(Vec<u8>, Vec<u8>)>);
/// Parsed representation of directory metadata.
pub struct DirMetaParsed {
/// The user ID.
pub uid: u32,
/// The group ID.
pub gid: u32,
/// The Unix mode, including file type flag.
pub mode: u32,
/// Extended attributes.
pub xattrs: Vec<(Vec<u8>, Vec<u8>)>,
}
impl DirMetaParsed {
/// Parse a directory metadata variant; must be of type `(uuua(ayay))`.
pub fn from_variant(
v: &glib::Variant,
) -> Result<DirMetaParsed, glib::variant::VariantTypeMismatchError> {
let (uid, gid, mode, xattrs) = v.try_get::<crate::DirmetaVariantType>()?;
Ok(DirMetaParsed {
uid: u32::from_be(uid),
gid: u32::from_be(gid),
mode: u32::from_be(mode),
xattrs,
})
}
}

View File

@ -0,0 +1,158 @@
#[cfg(any(feature = "v2017_13", feature = "dox"))]
use crate::ChecksumFlags;
use crate::{Checksum, ObjectType};
use glib::ffi::GFALSE;
use glib::{prelude::*, translate::*};
use std::{future::Future, mem::MaybeUninit, pin::Pin, ptr};
/// Compute the SHA-256 checksum of a file.
pub fn checksum_file<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(
f: &P,
objtype: ObjectType,
cancellable: Option<&Q>,
) -> Result<Checksum, Box<dyn std::error::Error>> {
unsafe {
let mut out_csum = ptr::null_mut();
let mut error = ptr::null_mut();
let ret = ffi::ostree_checksum_file(
f.as_ref().to_glib_none().0,
objtype.into_glib(),
&mut out_csum,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
checksum_file_error(out_csum, error, ret)
}
}
/// Asynchronously compute the SHA-256 checksum of a file.
pub fn checksum_file_async<
P: IsA<gio::File>,
Q: IsA<gio::Cancellable>,
R: FnOnce(Result<Checksum, Box<dyn std::error::Error>>) + Send + 'static,
>(
f: &P,
objtype: ObjectType,
io_priority: i32,
cancellable: Option<&Q>,
callback: R,
) {
let user_data: Box<R> = Box::new(callback);
unsafe extern "C" fn checksum_file_async_trampoline<
R: FnOnce(Result<Checksum, Box<dyn std::error::Error>>) + Send + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib::ffi::gpointer,
) {
let mut error = ptr::null_mut();
let mut out_csum = MaybeUninit::uninit();
let ret = ffi::ostree_checksum_file_async_finish(
_source_object as *mut _,
res,
out_csum.as_mut_ptr(),
&mut error,
);
let out_csum = out_csum.assume_init();
let result = checksum_file_error(out_csum, error, ret);
let callback: Box<R> = Box::from_raw(user_data as *mut _);
callback(result);
}
let callback = checksum_file_async_trampoline::<R>;
unsafe {
ffi::ostree_checksum_file_async(
f.as_ref().to_glib_none().0,
objtype.into_glib(),
io_priority,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
Some(callback),
Box::into_raw(user_data) as *mut _,
);
}
}
/// Asynchronously compute the SHA-256 checksum of a file.
#[allow(clippy::type_complexity)]
pub fn checksum_file_async_future<P: IsA<gio::File> + Clone + 'static>(
f: &P,
objtype: ObjectType,
io_priority: i32,
) -> Pin<Box<dyn Future<Output = Result<Checksum, Box<dyn std::error::Error>>> + 'static>> {
let f = f.clone();
Box::pin(gio::GioFuture::new(&f, move |f, cancellable, send| {
checksum_file_async(f, objtype, io_priority, Some(cancellable), move |res| {
send.resolve(res);
});
}))
}
/// Compute the OSTree checksum of a content object.
pub fn checksum_file_from_input<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(
file_info: &gio::FileInfo,
xattrs: Option<&glib::Variant>,
in_: Option<&P>,
objtype: ObjectType,
cancellable: Option<&Q>,
) -> Result<Checksum, Box<dyn std::error::Error>> {
unsafe {
let mut out_csum = ptr::null_mut();
let mut error = ptr::null_mut();
let ret = ffi::ostree_checksum_file_from_input(
file_info.to_glib_none().0,
xattrs.to_glib_none().0,
in_.map(|p| p.as_ref()).to_glib_none().0,
objtype.into_glib(),
&mut out_csum,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
checksum_file_error(out_csum, error, ret)
}
}
/// Compute the OSTree checksum of a file.
#[cfg(any(feature = "v2017_13", feature = "dox"))]
pub fn checksum_file_at<P: IsA<gio::Cancellable>>(
dfd: i32,
path: &std::path::Path,
stbuf: Option<&libc::stat>,
objtype: ObjectType,
flags: ChecksumFlags,
cancellable: Option<&P>,
) -> Result<glib::GString, glib::Error> {
unsafe {
let mut out_checksum = ptr::null_mut();
let mut error = ptr::null_mut();
ffi::ostree_checksum_file_at(
dfd,
path.to_glib_none().0,
stbuf
.map(|p| p as *const libc::stat as *mut libc::stat)
.unwrap_or(ptr::null_mut()),
objtype.into_glib(),
flags.into_glib(),
&mut out_checksum,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(out_checksum))
} else {
Err(from_glib_full(error))
}
}
}
unsafe fn checksum_file_error(
out_csum: *mut [*mut u8; 32],
error: *mut glib::ffi::GError,
ret: i32,
) -> Result<Checksum, Box<dyn std::error::Error>> {
if !error.is_null() {
Err(Box::<glib::Error>::new(from_glib_full(error)))
} else if ret == GFALSE {
Err(Box::new(glib::bool_error!("unknown error")))
} else {
Ok(Checksum::from_glib_full(out_csum))
}
}

View File

@ -0,0 +1,228 @@
use ffi::OstreeKernelArgs;
#[cfg(any(feature = "v2019_3", feature = "dox"))]
use glib::object::IsA;
use glib::translate::*;
#[cfg(any(feature = "v2019_3", feature = "dox"))]
use glib::GString;
use std::fmt;
use std::ptr;
glib::wrapper! {
/// Kernel arguments.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct KernelArgs(Boxed<ffi::OstreeKernelArgs>);
match fn {
copy => |_ptr| unimplemented!(),
free => |ptr| ffi::ostree_kernel_args_free(ptr),
}
}
impl KernelArgs {
/// Add a kernel argument.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn append(&mut self, arg: &str) {
unsafe {
ffi::ostree_kernel_args_append(self.to_glib_none_mut().0, arg.to_glib_none().0);
}
}
/// Add multiple kernel arguments.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn append_argv(&mut self, argv: &[&str]) {
unsafe {
ffi::ostree_kernel_args_append_argv(self.to_glib_none_mut().0, argv.to_glib_none().0);
}
}
/// Appends each argument that does not have one of `prefixes`.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn append_argv_filtered(&mut self, argv: &[&str], prefixes: &[&str]) {
unsafe {
ffi::ostree_kernel_args_append_argv_filtered(
self.to_glib_none_mut().0,
argv.to_glib_none().0,
prefixes.to_glib_none().0,
);
}
}
/// Append the entire contents of the currently booted kernel commandline.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn append_proc_cmdline<P: IsA<gio::Cancellable>>(
&mut self,
cancellable: Option<&P>,
) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_kernel_args_append_proc_cmdline(
self.to_glib_none_mut().0,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Remove a kernel argument.
pub fn delete(&mut self, arg: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_kernel_args_delete(
self.to_glib_none_mut().0,
arg.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Remove a kernel argument.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn delete_key_entry(&mut self, key: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_kernel_args_delete_key_entry(
self.to_glib_none_mut().0,
key.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Given `foo`, return the last the value of a `foo=bar` key as `bar`.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn get_last_value(&self, key: &str) -> Option<GString> {
unsafe {
from_glib_none(ffi::ostree_kernel_args_get_last_value(
self.to_glib_none().0 as *mut OstreeKernelArgs,
key.to_glib_none().0,
))
}
}
/// Replace any existing `foo=bar` with `foo=other` e.g.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn new_replace(&mut self, arg: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_kernel_args_new_replace(
self.to_glib_none_mut().0,
arg.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Append from a whitespace-separated string.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn parse_append(&mut self, options: &str) {
unsafe {
ffi::ostree_kernel_args_parse_append(
self.to_glib_none_mut().0,
options.to_glib_none().0,
);
}
}
/// Replace a kernel argument.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn replace(&mut self, arg: &str) {
unsafe {
ffi::ostree_kernel_args_replace(self.to_glib_none_mut().0, arg.to_glib_none().0);
}
}
/// Replace multiple kernel arguments.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn replace_argv(&mut self, argv: &[&str]) {
unsafe {
ffi::ostree_kernel_args_replace_argv(self.to_glib_none_mut().0, argv.to_glib_none().0);
}
}
/// A duplicate of `replace`.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn replace_take(&mut self, arg: &str) {
unsafe {
ffi::ostree_kernel_args_replace_take(self.to_glib_none_mut().0, arg.to_glib_full());
}
}
/// Convert the kernel arguments to a string.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
fn to_gstring(&self) -> GString {
unsafe {
from_glib_full(ffi::ostree_kernel_args_to_string(
self.to_glib_none().0 as *mut OstreeKernelArgs,
))
}
}
/// Convert the kernel arguments to a string array.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn to_strv(&self) -> Vec<GString> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::ostree_kernel_args_to_strv(
self.to_glib_none().0 as *mut OstreeKernelArgs,
))
}
}
// Not needed
//pub fn cleanup(loc: /*Unimplemented*/Option<Fundamental: Pointer>)
/// Parse the given string as kernel arguments.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn from_string(options: &str) -> KernelArgs {
unsafe {
from_glib_full(ffi::ostree_kernel_args_from_string(
options.to_glib_none().0,
))
}
}
/// Create new empty kernel arguments.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn new() -> KernelArgs {
unsafe { from_glib_full(ffi::ostree_kernel_args_new()) }
}
}
#[cfg(any(feature = "v2019_3", feature = "dox"))]
impl Default for KernelArgs {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for KernelArgs {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.to_gstring())
}
}
impl<T: AsRef<str>> From<T> for KernelArgs {
fn from(v: T) -> Self {
KernelArgs::from_string(v.as_ref())
}
}

95
rust-bindings/src/lib.rs Normal file
View File

@ -0,0 +1,95 @@
//! # Rust bindings for **libostree**
//!
//! [libostree](https://ostree.readthedocs.io) is both a shared library and suite of command line
//! tools that combines a "git-like" model for committing and downloading bootable filesystem trees,
//! along with a layer for deploying them and managing the bootloader configuration.
#![cfg_attr(feature = "dox", feature(doc_cfg))]
#![deny(unused_must_use)]
#![warn(missing_docs)]
#![warn(rustdoc::broken_intra_doc_links)]
// 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.
#[cfg(feature = "cap-std-apis")]
pub use cap_std;
pub use ffi;
pub use gio;
pub use glib;
/// Useful with `Repo::open_at()`.
pub use libc::AT_FDCWD;
// code generated by gir
#[rustfmt::skip]
#[allow(clippy::all)]
#[allow(unused_imports)]
#[allow(missing_docs)]
mod auto;
pub use crate::auto::functions::*;
pub use crate::auto::*;
// handwritten code
mod checksum;
pub use crate::checksum::*;
mod core;
pub use crate::core::*;
mod sysroot;
pub use crate::sysroot::*;
mod constants;
pub use constants::*;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
mod collection_ref;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
pub use crate::collection_ref::*;
mod functions;
pub use crate::functions::*;
mod mutable_tree;
pub use crate::mutable_tree::*;
#[cfg(any(feature = "v2019_3", feature = "dox"))]
mod kernel_args;
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub use crate::kernel_args::*;
mod object_name;
pub use crate::object_name::*;
mod object_details;
pub use crate::object_details::*;
mod repo;
pub use crate::repo::*;
#[cfg(any(feature = "v2016_8", feature = "dox"))]
mod repo_checkout_at_options;
#[cfg(any(feature = "v2016_8", feature = "dox"))]
pub use crate::repo_checkout_at_options::*;
mod repo_transaction_stats;
pub use repo_transaction_stats::RepoTransactionStats;
mod se_policy;
pub use crate::se_policy::*;
#[cfg(any(feature = "v2020_1", feature = "dox"))]
mod commit_sizes_entry;
#[cfg(any(feature = "v2020_1", feature = "dox"))]
pub use crate::commit_sizes_entry::*;
#[cfg(any(feature = "v2017_4", feature = "dox"))]
mod sysroot_write_deployments_opts;
#[cfg(any(feature = "v2017_4", feature = "dox"))]
pub use crate::sysroot_write_deployments_opts::*;
#[cfg(any(feature = "v2020_7", feature = "dox"))]
mod sysroot_deploy_tree_opts;
#[cfg(any(feature = "v2020_7", feature = "dox"))]
pub use crate::sysroot_deploy_tree_opts::SysrootDeployTreeOpts;
// tests
#[cfg(test)]
mod tests;
/// Prelude, intended for glob imports.
pub mod prelude {
pub use crate::auto::traits::*;
// See "Re-export dependencies above".
#[doc(hidden)]
pub use gio::prelude::*;
#[doc(hidden)]
pub use glib::prelude::*;
}

View File

@ -0,0 +1,46 @@
use crate::MutableTree;
use glib::{self, translate::*};
use std::collections::HashMap;
impl MutableTree {
#[doc(alias = "ostree_mutable_tree_get_files")]
/// Create a copy of the files in this mutable tree.
/// Unlike the C version of this function, a copy is made because providing
/// read-write access would introduce the potential for use-after-free bugs.
pub fn copy_files(&self) -> HashMap<String, String> {
unsafe {
let v = ffi::ostree_mutable_tree_get_files(self.to_glib_none().0);
HashMap::from_glib_none_num(v, 1)
}
}
#[doc(alias = "ostree_mutable_tree_get_subdirs")]
/// Create a copy of the directories in this mutable tree.
/// Unlike the C version of this function, a copy is made because providing
/// read-write access would introduce the potential for use-after-free bugs.
pub fn copy_subdirs(&self) -> HashMap<String, Self> {
use glib::ffi::gpointer;
unsafe {
let v = ffi::ostree_mutable_tree_get_subdirs(self.to_glib_none().0);
unsafe extern "C" fn visit_hash_table(
key: gpointer,
value: gpointer,
hash_map: gpointer,
) {
let key: String = from_glib_none(key as *const libc::c_char);
let value: MutableTree = from_glib_none(value as *const ffi::OstreeMutableTree);
let hash_map: &mut HashMap<String, MutableTree> =
&mut *(hash_map as *mut HashMap<String, MutableTree>);
hash_map.insert(key, value);
}
let mut map = HashMap::with_capacity(glib::ffi::g_hash_table_size(v) as usize);
glib::ffi::g_hash_table_foreach(
v,
Some(visit_hash_table),
&mut map as *mut HashMap<String, MutableTree> as *mut _,
);
map
}
}
}

View File

@ -0,0 +1,44 @@
use std::fmt::Display;
use std::fmt::Error;
use std::fmt::Formatter;
/// Details of an object in an OSTree repo. It contains information about if
/// the object is "loose", and contains a list of pack file checksums in which
/// this object appears.
#[derive(Debug)]
pub struct ObjectDetails {
loose: bool,
object_appearances: Vec<String>,
}
impl ObjectDetails {
/// Create a new `ObjectDetails` from a serialized representation.
pub fn new_from_variant(variant: glib::Variant) -> Option<ObjectDetails> {
let deserialize = variant.get::<(bool, Vec<String>)>()?;
Some(ObjectDetails {
loose: deserialize.0,
object_appearances: deserialize.1,
})
}
/// is object available "loose"
pub fn is_loose(&self) -> bool {
self.loose
}
/// Provide list of pack file checksums in which the object appears
pub fn appearances(&self) -> &Vec<String> {
&self.object_appearances
}
}
impl Display for ObjectDetails {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
write!(
f,
"Object is {} and appears in {} checksums",
if self.loose { "loose" } else { "not loose" },
self.object_appearances.len()
)
}
}

View File

@ -0,0 +1,115 @@
use crate::ObjectType;
use crate::{object_name_deserialize, object_name_serialize, object_to_string};
use glib::translate::*;
use glib::GString;
use std::fmt::Display;
use std::fmt::Error;
use std::fmt::Formatter;
use std::hash::Hash;
use std::hash::Hasher;
fn hash_object_name(v: &glib::Variant) -> u32 {
unsafe { ffi::ostree_hash_object_name(v.to_glib_none().0 as glib::ffi::gconstpointer) }
}
/// A reference to an object in an OSTree repo. It contains both a checksum and an
/// [ObjectType](enum.ObjectType.html) which together identify an object in a repository.
#[derive(Eq, Debug)]
pub struct ObjectName {
variant: glib::Variant,
checksum: GString,
object_type: ObjectType,
}
impl ObjectName {
/// Create a new `ObjectName` from a serialized representation.
pub fn new_from_variant(variant: glib::Variant) -> ObjectName {
let deserialize = object_name_deserialize(&variant);
ObjectName {
variant,
checksum: deserialize.0,
object_type: deserialize.1,
}
}
/// Create a new `ObjectName` with the given checksum and `ObjectType`.
pub fn new<S: Into<GString>>(checksum: S, object_type: ObjectType) -> ObjectName {
let checksum = checksum.into();
let variant = object_name_serialize(checksum.as_str(), object_type)
.expect("type checks should make this safe");
ObjectName {
variant,
checksum,
object_type,
}
}
/// Return a reference to this `ObjectName`'s checksum string.
pub fn checksum(&self) -> &str {
self.checksum.as_str()
}
/// Return this `ObjectName`'s `ObjectType`.
pub fn object_type(&self) -> ObjectType {
self.object_type
}
/// Format this `ObjectName` as a string.
fn to_string(&self) -> GString {
object_to_string(self.checksum(), self.object_type())
.expect("type checks should make this safe")
}
}
impl Display for ObjectName {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
write!(f, "{}", self.to_string())
}
}
impl Hash for ObjectName {
fn hash<H: Hasher>(&self, state: &mut H) {
state.write_u32(hash_object_name(&self.variant));
}
}
impl PartialEq for ObjectName {
fn eq(&self, other: &ObjectName) -> bool {
self.checksum == other.checksum && self.object_type == other.object_type
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn should_stringify_object_name() {
let object_name = ObjectName::new("abcdef123456", ObjectType::DirTree);
let stringified = format!("{}", object_name);
assert_eq!(stringified, "abcdef123456.dirtree");
}
#[test]
fn same_values_should_be_equal() {
let a = ObjectName::new("abc123", ObjectType::File);
let b = ObjectName::new("abc123", ObjectType::File);
assert_eq!(a, b);
}
#[test]
fn different_values_should_not_be_equal() {
let a = ObjectName::new("abc123", ObjectType::Commit);
let b = ObjectName::new("abc123", ObjectType::File);
assert_ne!(a, b);
}
#[test]
fn should_create_object_name_from_variant() {
let object_name = ObjectName::new("123456", ObjectType::CommitMeta);
let from_variant = ObjectName::new_from_variant(object_name.variant.clone());
assert_eq!(object_name, from_variant);
assert_eq!("123456", from_variant.checksum());
assert_eq!(ObjectType::CommitMeta, from_variant.object_type());
}
}

524
rust-bindings/src/repo.rs Normal file
View File

@ -0,0 +1,524 @@
#[cfg(any(feature = "v2016_4", feature = "dox"))]
use crate::RepoListRefsExtFlags;
#[cfg(feature = "cap-std-apis")]
use crate::RepoMode;
use crate::{Checksum, ObjectDetails, ObjectName, ObjectType, Repo, RepoTransactionStats};
use ffi::OstreeRepoListObjectsFlags;
use glib::ffi as glib_sys;
use glib::{self, translate::*, Error, IsA};
use std::{
collections::{HashMap, HashSet},
future::Future,
mem::MaybeUninit,
path::Path,
pin::Pin,
ptr,
};
unsafe extern "C" fn read_variant_table(
_key: glib_sys::gpointer,
value: glib_sys::gpointer,
hash_set: glib_sys::gpointer,
) {
let value: glib::Variant = from_glib_none(value as *const glib_sys::GVariant);
let set: &mut HashSet<ObjectName> = &mut *(hash_set as *mut HashSet<ObjectName>);
set.insert(ObjectName::new_from_variant(value));
}
unsafe extern "C" fn read_variant_object_map(
key: glib_sys::gpointer,
value: glib_sys::gpointer,
hash_set: glib_sys::gpointer,
) {
let key: glib::Variant = from_glib_none(key as *const glib_sys::GVariant);
let value: glib::Variant = from_glib_none(value as *const glib_sys::GVariant);
let set: &mut HashMap<ObjectName, ObjectDetails> =
&mut *(hash_set as *mut HashMap<ObjectName, ObjectDetails>);
if let Some(details) = ObjectDetails::new_from_variant(value) {
set.insert(ObjectName::new_from_variant(key), details);
}
}
unsafe fn from_glib_container_variant_set(ptr: *mut glib_sys::GHashTable) -> HashSet<ObjectName> {
let mut set = HashSet::new();
glib_sys::g_hash_table_foreach(
ptr,
Some(read_variant_table),
&mut set as *mut HashSet<ObjectName> as *mut _,
);
glib_sys::g_hash_table_unref(ptr);
set
}
unsafe fn from_glib_container_variant_map(
ptr: *mut glib_sys::GHashTable,
) -> HashMap<ObjectName, ObjectDetails> {
let mut set = HashMap::new();
glib_sys::g_hash_table_foreach(
ptr,
Some(read_variant_object_map),
&mut set as *mut HashMap<ObjectName, ObjectDetails> as *mut _,
);
glib_sys::g_hash_table_unref(ptr);
set
}
/// An open transaction in the repository.
///
/// This will automatically invoke [`ostree::Repo::abort_transaction`] when the value is dropped.
pub struct TransactionGuard<'a> {
/// Reference to the repository for this transaction.
repo: Option<&'a Repo>,
}
impl<'a> TransactionGuard<'a> {
/// Returns a reference to the repository.
pub fn repo(&self) -> &Repo {
// SAFETY: This is only set to None in `commit`, which consumes self
self.repo.unwrap()
}
/// Commit this transaction.
pub fn commit<P: IsA<gio::Cancellable>>(
mut self,
cancellable: Option<&P>,
) -> Result<RepoTransactionStats, glib::Error> {
// Safety: This is the only function which mutates this option
let repo = self.repo.take().unwrap();
repo.commit_transaction(cancellable)
}
}
impl<'a> Drop for TransactionGuard<'a> {
fn drop(&mut self) {
if let Some(repo) = self.repo {
// TODO: better logging in ostree?
// See also https://github.com/ostreedev/ostree/issues/2413
let _ = repo.abort_transaction(gio::NONE_CANCELLABLE);
}
}
}
impl Repo {
/// Create a new `Repo` object for working with an OSTree repo at the given path.
pub fn new_for_path<P: AsRef<Path>>(path: P) -> Repo {
Repo::new(&gio::File::for_path(path.as_ref()))
}
#[cfg(feature = "cap-std-apis")]
/// A version of [`open_at`] which uses cap-std.
pub fn open_at_dir(dir: &cap_std::fs::Dir, path: &str) -> Result<Repo, glib::Error> {
use std::os::unix::io::AsRawFd;
crate::Repo::open_at(dir.as_raw_fd(), path, gio::NONE_CANCELLABLE)
}
#[cfg(feature = "cap-std-apis")]
/// A version of [`create_at`] which uses cap-std, and also returns the opened repo.
pub fn create_at_dir(
dir: &cap_std::fs::Dir,
path: &str,
mode: RepoMode,
options: Option<&glib::Variant>,
) -> Result<Repo, glib::Error> {
use std::os::unix::io::AsRawFd;
crate::Repo::create_at(dir.as_raw_fd(), path, mode, options, gio::NONE_CANCELLABLE)?;
Repo::open_at_dir(dir, path)
}
/// A wrapper for [`prepare_transaction`] which ensures the transaction will be aborted when the guard goes out of scope.
pub fn auto_transaction<P: IsA<gio::Cancellable>>(
&self,
cancellable: Option<&P>,
) -> Result<TransactionGuard, glib::Error> {
let _ = self.prepare_transaction(cancellable)?;
Ok(TransactionGuard { repo: Some(self) })
}
/// Return a copy of the directory file descriptor for this repository.
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
pub fn dfd_as_file(&self) -> std::io::Result<std::fs::File> {
use std::os::unix::prelude::FromRawFd;
use std::os::unix::prelude::IntoRawFd;
unsafe {
// A temporary owned file instance
let dfd = std::fs::File::from_raw_fd(self.dfd());
// So we can call dup() on it
let copy = dfd.try_clone();
// Now release our temporary ownership of the original
let _ = dfd.into_raw_fd();
copy
}
}
/// Borrow the directory file descriptor for this repository.
#[cfg(feature = "cap-std-apis")]
pub fn dfd_borrow<'a>(&'a self) -> io_lifetimes::BorrowedFd<'a> {
unsafe { io_lifetimes::BorrowedFd::borrow_raw_fd(self.dfd()) }
}
/// Return a new `cap-std` directory reference for this repository.
#[cfg(feature = "cap-std-apis")]
pub fn dfd_as_dir(&self) -> std::io::Result<cap_std::fs::Dir> {
cap_std::fs::Dir::reopen_dir(&self.dfd_borrow())
}
/// Find all objects reachable from a commit.
pub fn traverse_commit<P: IsA<gio::Cancellable>>(
&self,
commit_checksum: &str,
maxdepth: i32,
cancellable: Option<&P>,
) -> Result<HashSet<ObjectName>, Error> {
unsafe {
let mut error = ptr::null_mut();
let mut hashtable = ptr::null_mut();
let _ = ffi::ostree_repo_traverse_commit(
self.to_glib_none().0,
commit_checksum.to_glib_none().0,
maxdepth,
&mut hashtable,
cancellable.map(AsRef::as_ref).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_container_variant_set(hashtable))
} else {
Err(from_glib_full(error))
}
}
}
/// List all branch names (refs).
pub fn list_refs<P: IsA<gio::Cancellable>>(
&self,
refspec_prefix: Option<&str>,
cancellable: Option<&P>,
) -> Result<HashMap<String, String>, Error> {
unsafe {
let mut error = ptr::null_mut();
let mut hashtable = ptr::null_mut();
let _ = ffi::ostree_repo_list_refs(
self.to_glib_none().0,
refspec_prefix.to_glib_none().0,
&mut hashtable,
cancellable.map(AsRef::as_ref).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(FromGlibPtrContainer::from_glib_container(hashtable))
} else {
Err(from_glib_full(error))
}
}
}
/// List all repo objects
pub fn list_objects<P: IsA<gio::Cancellable>>(
&self,
flags: OstreeRepoListObjectsFlags,
cancellable: Option<&P>,
) -> Result<HashMap<ObjectName, ObjectDetails>, Error> {
unsafe {
let mut error = ptr::null_mut();
let mut hashtable = ptr::null_mut();
ffi::ostree_repo_list_objects(
self.to_glib_none().0,
flags,
&mut hashtable,
cancellable.map(AsRef::as_ref).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_container_variant_map(hashtable))
} else {
Err(from_glib_full(error))
}
}
}
/// List refs with extended options.
#[cfg(any(feature = "v2016_4", feature = "dox"))]
pub fn list_refs_ext<P: IsA<gio::Cancellable>>(
&self,
refspec_prefix: Option<&str>,
flags: RepoListRefsExtFlags,
cancellable: Option<&P>,
) -> Result<HashMap<String, String>, Error> {
unsafe {
let mut error = ptr::null_mut();
let mut hashtable = ptr::null_mut();
let _ = ffi::ostree_repo_list_refs_ext(
self.to_glib_none().0,
refspec_prefix.to_glib_none().0,
&mut hashtable,
flags.into_glib(),
cancellable.map(AsRef::as_ref).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(FromGlibPtrContainer::from_glib_container(hashtable))
} else {
Err(from_glib_full(error))
}
}
}
/// Resolve a refspec to a commit SHA256.
/// Returns an error if the refspec does not exist.
pub fn require_rev(&self, refspec: &str) -> Result<glib::GString, Error> {
// SAFETY: Since we said `false` for "allow_noent", this function must return a value
Ok(self.resolve_rev(refspec, false)?.unwrap())
}
/// Query metadata for a content object.
///
/// This is similar to [`load_file`], but is more efficient if reading the file content is not needed.
pub fn query_file<P: IsA<gio::Cancellable>>(
&self,
checksum: &str,
cancellable: Option<&P>,
) -> Result<(gio::FileInfo, glib::Variant), glib::Error> {
unsafe {
let mut out_file_info = ptr::null_mut();
let mut out_xattrs = ptr::null_mut();
let mut error = ptr::null_mut();
let r = ffi::ostree_repo_load_file(
self.to_glib_none().0,
checksum.to_glib_none().0,
ptr::null_mut(),
&mut out_file_info,
&mut out_xattrs,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if error.is_null() {
debug_assert!(r != 0);
Ok((from_glib_full(out_file_info), from_glib_full(out_xattrs)))
} else {
debug_assert_eq!(r, 0);
Err(from_glib_full(error))
}
}
}
/// Write a content object from provided input.
pub fn write_content<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(
&self,
expected_checksum: Option<&str>,
object_input: &P,
length: u64,
cancellable: Option<&Q>,
) -> Result<Checksum, Error> {
unsafe {
let mut error = ptr::null_mut();
let mut out_csum = ptr::null_mut();
let _ = ffi::ostree_repo_write_content(
self.to_glib_none().0,
expected_checksum.to_glib_none().0,
object_input.as_ref().to_glib_none().0,
length,
&mut out_csum,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(out_csum))
} else {
Err(from_glib_full(error))
}
}
}
/// Write a metadata object.
pub fn write_metadata<P: IsA<gio::Cancellable>>(
&self,
objtype: ObjectType,
expected_checksum: Option<&str>,
object: &glib::Variant,
cancellable: Option<&P>,
) -> Result<Checksum, Error> {
unsafe {
let mut error = ptr::null_mut();
let mut out_csum = ptr::null_mut();
let _ = ffi::ostree_repo_write_metadata(
self.to_glib_none().0,
objtype.into_glib(),
expected_checksum.to_glib_none().0,
object.to_glib_none().0,
&mut out_csum,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(out_csum))
} else {
Err(from_glib_full(error))
}
}
}
/// Asynchronously write a content object.
pub fn write_content_async<
P: IsA<gio::InputStream>,
Q: IsA<gio::Cancellable>,
R: FnOnce(Result<Checksum, Error>) + Send + 'static,
>(
&self,
expected_checksum: Option<&str>,
object: &P,
length: u64,
cancellable: Option<&Q>,
callback: R,
) {
let user_data: Box<R> = Box::new(callback);
unsafe extern "C" fn write_content_async_trampoline<
R: FnOnce(Result<Checksum, Error>) + Send + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib::ffi::gpointer,
) {
let mut error = ptr::null_mut();
let mut out_csum = MaybeUninit::uninit();
let _ = ffi::ostree_repo_write_content_finish(
_source_object as *mut _,
res,
out_csum.as_mut_ptr(),
&mut error,
);
let out_csum = out_csum.assume_init();
let result = if error.is_null() {
Ok(Checksum::from_glib_full(out_csum))
} else {
Err(from_glib_full(error))
};
let callback: Box<R> = Box::from_raw(user_data as *mut _);
callback(result);
}
let callback = write_content_async_trampoline::<R>;
unsafe {
ffi::ostree_repo_write_content_async(
self.to_glib_none().0,
expected_checksum.to_glib_none().0,
object.as_ref().to_glib_none().0,
length,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
Some(callback),
Box::into_raw(user_data) as *mut _,
);
}
}
/// Asynchronously write a content object.
pub fn write_content_async_future<P: IsA<gio::InputStream> + Clone + 'static>(
&self,
expected_checksum: Option<&str>,
object: &P,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<Checksum, Error>> + 'static>> {
let expected_checksum = expected_checksum.map(ToOwned::to_owned);
let object = object.clone();
Box::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
obj.write_content_async(
expected_checksum
.as_ref()
.map(::std::borrow::Borrow::borrow),
&object,
length,
Some(cancellable),
move |res| {
send.resolve(res);
},
);
}))
}
/// Asynchronously write a metadata object.
pub fn write_metadata_async<
P: IsA<gio::Cancellable>,
Q: FnOnce(Result<Checksum, Error>) + Send + 'static,
>(
&self,
objtype: ObjectType,
expected_checksum: Option<&str>,
object: &glib::Variant,
cancellable: Option<&P>,
callback: Q,
) {
let user_data: Box<Q> = Box::new(callback);
unsafe extern "C" fn write_metadata_async_trampoline<
Q: FnOnce(Result<Checksum, Error>) + Send + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib_sys::gpointer,
) {
let mut error = ptr::null_mut();
let mut out_csum = MaybeUninit::uninit();
let _ = ffi::ostree_repo_write_metadata_finish(
_source_object as *mut _,
res,
out_csum.as_mut_ptr(),
&mut error,
);
let out_csum = out_csum.assume_init();
let result = if error.is_null() {
Ok(Checksum::from_glib_full(out_csum))
} else {
Err(from_glib_full(error))
};
let callback: Box<Q> = Box::from_raw(user_data as *mut _);
callback(result);
}
let callback = write_metadata_async_trampoline::<Q>;
unsafe {
ffi::ostree_repo_write_metadata_async(
self.to_glib_none().0,
objtype.into_glib(),
expected_checksum.to_glib_none().0,
object.to_glib_none().0,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
Some(callback),
Box::into_raw(user_data) as *mut _,
);
}
}
/// Asynchronously write a metadata object.
pub fn write_metadata_async_future(
&self,
objtype: ObjectType,
expected_checksum: Option<&str>,
object: &glib::Variant,
) -> Pin<Box<dyn Future<Output = Result<Checksum, Error>> + 'static>> {
let expected_checksum = expected_checksum.map(ToOwned::to_owned);
let object = object.clone();
Box::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
obj.write_metadata_async(
objtype,
expected_checksum
.as_ref()
.map(::std::borrow::Borrow::borrow),
&object,
Some(cancellable),
move |res| {
send.resolve(res);
},
);
}))
}
/// Load and parse directory metadata.
/// In particular, uid/gid/mode are stored in big-endian format; this function
/// converts them to host native endianness.
pub fn read_dirmeta(&self, checksum: &str) -> Result<crate::DirMetaParsed, glib::Error> {
let v = self.load_variant(crate::ObjectType::DirMeta, checksum)?;
// Safety: We know the variant type will match since we just passed it above
Ok(crate::DirMetaParsed::from_variant(&v).unwrap())
}
}

View File

@ -0,0 +1,280 @@
use crate::{RepoCheckoutMode, RepoCheckoutOverwriteMode, RepoDevInoCache, SePolicy};
use glib::translate::*;
use libc::c_char;
use std::path::PathBuf;
#[cfg(any(feature = "v2018_2", feature = "dox"))]
mod repo_checkout_filter;
#[cfg(any(feature = "v2018_2", feature = "dox"))]
pub use self::repo_checkout_filter::RepoCheckoutFilter;
/// Options for checking out an OSTree commit.
pub struct RepoCheckoutAtOptions {
/// Checkout mode.
pub mode: RepoCheckoutMode,
/// Overwrite mode.
pub overwrite_mode: RepoCheckoutOverwriteMode,
/// Deprecated, do not use.
pub enable_uncompressed_cache: bool,
/// Perform `fsync()` on checked out files and directories.
pub enable_fsync: bool,
/// Handle OCI/Docker style whiteout files.
pub process_whiteouts: bool,
/// Require hardlinking.
pub no_copy_fallback: bool,
/// Never hardlink; reflink if possible, otherwise full physical copy.
#[cfg(any(feature = "v2017_6", feature = "dox"))]
pub force_copy: bool,
/// Suppress mode bits outside of 0775 for directories.
#[cfg(any(feature = "v2017_7", feature = "dox"))]
pub bareuseronly_dirs: bool,
/// Copy zero-sized files rather than hardlinking.
#[cfg(any(feature = "v2018_9", feature = "dox"))]
pub force_copy_zerosized: bool,
/// Only check out this subpath.
pub subpath: Option<PathBuf>,
/// A cache from device, inode pairs to checksums.
pub devino_to_csum_cache: Option<RepoDevInoCache>,
/// A callback function to decide which files and directories will be checked out from the
/// repo. See the documentation on [RepoCheckoutFilter](struct.RepoCheckoutFilter.html) for more
/// information on the signature.
///
/// # Panics
/// This callback may not panic. If it does, `abort()` will be called to avoid unwinding across
/// an FFI boundary and into the libostree C code (which is Undefined Behavior). If you prefer to
/// swallow the panic rather than aborting, you can use `std::panic::catch_unwind` inside your
/// callback to catch and silence any panics that occur.
#[cfg(any(feature = "v2018_2", feature = "dox"))]
pub filter: Option<RepoCheckoutFilter>,
/// SELinux policy.
#[cfg(any(feature = "v2017_6", feature = "dox"))]
pub sepolicy: Option<SePolicy>,
/// When computing security contexts, prefix the path with this value.
pub sepolicy_prefix: Option<String>,
}
impl Default for RepoCheckoutAtOptions {
fn default() -> Self {
RepoCheckoutAtOptions {
mode: RepoCheckoutMode::None,
overwrite_mode: RepoCheckoutOverwriteMode::None,
enable_uncompressed_cache: false,
enable_fsync: false,
process_whiteouts: false,
no_copy_fallback: false,
#[cfg(feature = "v2017_6")]
force_copy: false,
#[cfg(feature = "v2017_7")]
bareuseronly_dirs: false,
#[cfg(feature = "v2018_9")]
force_copy_zerosized: false,
subpath: None,
devino_to_csum_cache: None,
#[cfg(feature = "v2018_2")]
filter: None,
#[cfg(feature = "v2017_6")]
sepolicy: None,
sepolicy_prefix: None,
}
}
}
type StringStash<'a, T> = Stash<'a, *const c_char, Option<T>>;
type WrapperStash<'a, GlibT, WrappedT> = Stash<'a, *mut GlibT, Option<WrappedT>>;
impl<'a> ToGlibPtr<'a, *const ffi::OstreeRepoCheckoutAtOptions> for RepoCheckoutAtOptions {
#[allow(clippy::type_complexity)]
type Storage = (
Box<ffi::OstreeRepoCheckoutAtOptions>,
StringStash<'a, PathBuf>,
StringStash<'a, String>,
WrapperStash<'a, ffi::OstreeRepoDevInoCache, RepoDevInoCache>,
WrapperStash<'a, ffi::OstreeSePolicy, SePolicy>,
);
// We need to make sure that all memory pointed to by the returned pointer is kept alive by
// either the `self` reference or the returned Stash.
fn to_glib_none(&'a self) -> Stash<*const ffi::OstreeRepoCheckoutAtOptions, Self> {
// Creating this struct from zeroed memory is fine since it's `repr(C)` and only contains
// primitive types. In fact, the libostree docs say to zero the struct. This means we handle
// the unused bytes correctly.
// The struct needs to be boxed so the pointer we return remains valid even as the Stash is
// moved around.
let mut options =
Box::new(unsafe { std::mem::zeroed::<ffi::OstreeRepoCheckoutAtOptions>() });
options.mode = self.mode.into_glib();
options.overwrite_mode = self.overwrite_mode.into_glib();
options.enable_uncompressed_cache = self.enable_uncompressed_cache.into_glib();
options.enable_fsync = self.enable_fsync.into_glib();
options.process_whiteouts = self.process_whiteouts.into_glib();
options.no_copy_fallback = self.no_copy_fallback.into_glib();
#[cfg(feature = "v2017_6")]
{
options.force_copy = self.force_copy.into_glib();
}
#[cfg(feature = "v2017_7")]
{
options.bareuseronly_dirs = self.bareuseronly_dirs.into_glib();
}
#[cfg(feature = "v2018_9")]
{
options.force_copy_zerosized = self.force_copy_zerosized.into_glib();
}
// We keep these complex values alive by returning them in our Stash. Technically, some of
// these are being kept alive by `self` already, but it's better to be consistent here.
let subpath = self.subpath.to_glib_none();
options.subpath = subpath.0;
let sepolicy_prefix = self.sepolicy_prefix.to_glib_none();
options.sepolicy_prefix = sepolicy_prefix.0;
let devino_to_csum_cache = self.devino_to_csum_cache.to_glib_none();
options.devino_to_csum_cache = devino_to_csum_cache.0;
#[cfg(feature = "v2017_6")]
let sepolicy = {
let sepolicy = self.sepolicy.to_glib_none();
options.sepolicy = sepolicy.0;
sepolicy
};
#[cfg(not(feature = "v2017_6"))]
let sepolicy = None.to_glib_none();
#[cfg(feature = "v2018_2")]
{
if let Some(filter) = &self.filter {
options.filter_user_data = filter.to_glib_none().0;
options.filter = Some(repo_checkout_filter::filter_trampoline_unwindsafe);
}
}
Stash(
options.as_ref(),
(
options,
subpath,
sepolicy_prefix,
devino_to_csum_cache,
sepolicy,
),
)
}
}
#[cfg(test)]
mod tests {
use super::*;
use glib::ffi::{GFALSE, GTRUE};
use std::ffi::{CStr, CString};
use std::ptr;
#[test]
fn should_convert_default_options() {
let options = RepoCheckoutAtOptions::default();
let stash = options.to_glib_none();
let ptr = stash.0;
unsafe {
assert_eq!((*ptr).mode, ffi::OSTREE_REPO_CHECKOUT_MODE_NONE);
assert_eq!(
(*ptr).overwrite_mode,
ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_NONE
);
assert_eq!((*ptr).enable_uncompressed_cache, GFALSE);
assert_eq!((*ptr).enable_fsync, GFALSE);
assert_eq!((*ptr).process_whiteouts, GFALSE);
assert_eq!((*ptr).no_copy_fallback, GFALSE);
#[cfg(feature = "v2017_6")]
assert_eq!((*ptr).force_copy, GFALSE);
#[cfg(feature = "v2017_7")]
assert_eq!((*ptr).bareuseronly_dirs, GFALSE);
#[cfg(feature = "v2018_9")]
assert_eq!((*ptr).force_copy_zerosized, GFALSE);
assert_eq!((*ptr).unused_bools, [GFALSE; 4]);
assert_eq!((*ptr).subpath, ptr::null());
assert_eq!((*ptr).devino_to_csum_cache, ptr::null_mut());
assert_eq!((*ptr).unused_ints, [0; 6]);
assert_eq!((*ptr).unused_ptrs, [ptr::null_mut(); 3]);
#[cfg(feature = "v2018_2")]
assert_eq!((*ptr).filter, None);
#[cfg(feature = "v2018_2")]
assert_eq!((*ptr).filter_user_data, ptr::null_mut());
#[cfg(feature = "v2017_6")]
assert_eq!((*ptr).sepolicy, ptr::null_mut());
assert_eq!((*ptr).sepolicy_prefix, ptr::null());
}
}
#[test]
fn should_convert_non_default_options() {
let options = RepoCheckoutAtOptions {
mode: RepoCheckoutMode::User,
overwrite_mode: RepoCheckoutOverwriteMode::UnionIdentical,
enable_uncompressed_cache: true,
enable_fsync: true,
process_whiteouts: true,
no_copy_fallback: true,
#[cfg(feature = "v2017_6")]
force_copy: true,
#[cfg(feature = "v2017_7")]
bareuseronly_dirs: true,
#[cfg(feature = "v2018_9")]
force_copy_zerosized: true,
subpath: Some("sub/path".into()),
devino_to_csum_cache: Some(RepoDevInoCache::new()),
#[cfg(feature = "v2018_2")]
filter: RepoCheckoutFilter::new(|_repo, _path, _stat| {
crate::RepoCheckoutFilterResult::Skip
}),
#[cfg(feature = "v2017_6")]
sepolicy: Some(
SePolicy::new(&gio::File::for_path("a/b"), gio::NONE_CANCELLABLE).unwrap(),
),
sepolicy_prefix: Some("prefix".into()),
};
let stash = options.to_glib_none();
let ptr = stash.0;
unsafe {
assert_eq!((*ptr).mode, ffi::OSTREE_REPO_CHECKOUT_MODE_USER);
assert_eq!(
(*ptr).overwrite_mode,
ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL
);
assert_eq!((*ptr).enable_uncompressed_cache, GTRUE);
assert_eq!((*ptr).enable_fsync, GTRUE);
assert_eq!((*ptr).process_whiteouts, GTRUE);
assert_eq!((*ptr).no_copy_fallback, GTRUE);
#[cfg(feature = "v2017_6")]
assert_eq!((*ptr).force_copy, GTRUE);
#[cfg(feature = "v2017_7")]
assert_eq!((*ptr).bareuseronly_dirs, GTRUE);
#[cfg(feature = "v2018_9")]
assert_eq!((*ptr).force_copy_zerosized, GTRUE);
assert_eq!((*ptr).unused_bools, [GFALSE; 4]);
assert_eq!(
CStr::from_ptr((*ptr).subpath),
CString::new("sub/path").unwrap().as_c_str()
);
assert_eq!(
(*ptr).devino_to_csum_cache,
options.devino_to_csum_cache.to_glib_none().0
);
assert_eq!((*ptr).unused_ints, [0; 6]);
assert_eq!((*ptr).unused_ptrs, [ptr::null_mut(); 3]);
#[cfg(feature = "v2018_2")]
assert!((*ptr).filter == Some(repo_checkout_filter::filter_trampoline_unwindsafe));
#[cfg(feature = "v2018_2")]
assert_eq!(
(*ptr).filter_user_data,
options.filter.as_ref().unwrap().to_glib_none().0,
);
#[cfg(feature = "v2017_6")]
assert_eq!((*ptr).sepolicy, options.sepolicy.to_glib_none().0);
assert_eq!(
CStr::from_ptr((*ptr).sepolicy_prefix),
CString::new("prefix").unwrap().as_c_str()
);
}
}
}

View File

@ -0,0 +1,217 @@
use crate::{Repo, RepoCheckoutFilterResult};
use glib::ffi::gpointer;
use glib::translate::*;
use libc::c_char;
use std::any::Any;
use std::panic::catch_unwind;
use std::path::{Path, PathBuf};
use std::process::abort;
/// A filter callback to decide which files to checkout from a [Repo](struct.Repo.html). The
/// function is called for every directory and file in the dirtree.
///
/// # Arguments
/// * `repo` - the `Repo` that is being checked out
/// * `path` - the path of the current file, as an absolute path rooted at the commit's root. The
/// root directory is '/', a subdir would be '/subdir' etc.
/// * `stat` - the metadata of the current file
///
/// # Return Value
/// The return value determines whether the current file is checked out or skipped.
pub struct RepoCheckoutFilter(Box<dyn Fn(&Repo, &Path, &libc::stat) -> RepoCheckoutFilterResult>);
impl RepoCheckoutFilter {
/// Wrap a closure for use as a filter function.
///
/// # Return Value
/// The return value is always `Some` containing the value. It simply comes pre-wrapped for your
/// convenience.
pub fn new<F>(closure: F) -> Option<RepoCheckoutFilter>
where
F: (Fn(&Repo, &Path, &libc::stat) -> RepoCheckoutFilterResult) + 'static,
{
Some(RepoCheckoutFilter(Box::new(closure)))
}
/// Call the contained closure.
fn call(&self, repo: &Repo, path: &Path, stat: &libc::stat) -> RepoCheckoutFilterResult {
self.0(repo, path, stat)
}
}
impl<'a> ToGlibPtr<'a, gpointer> for RepoCheckoutFilter {
type Storage = ();
fn to_glib_none(&'a self) -> Stash<gpointer, Self> {
Stash(self as *const RepoCheckoutFilter as gpointer, ())
}
}
impl FromGlibPtrNone<gpointer> for &RepoCheckoutFilter {
// `ptr` must be valid for the lifetime of the returned reference.
unsafe fn from_glib_none(ptr: gpointer) -> Self {
assert!(!ptr.is_null());
&*(ptr as *const RepoCheckoutFilter)
}
}
/// Trampoline to be called by libostree that calls the Rust closure in the `user_data` parameter.
///
/// # Safety
/// All parameters must be valid pointers for the runtime of the function. In particular,
/// `user_data` must point to a [RepoCheckoutFilter](struct.RepoCheckoutFilter.html) value.
///
/// # Panics
/// If any parameter is a null pointer, the function panics.
unsafe fn filter_trampoline(
repo: *mut ffi::OstreeRepo,
path: *const c_char,
stat: *mut libc::stat,
user_data: gpointer,
) -> ffi::OstreeRepoCheckoutFilterResult {
// We can't guarantee it's a valid pointer, but we can make sure it's not null.
assert!(!stat.is_null());
let stat = &*stat;
// This reference is valid until the end of this function, which is shorter than the lifetime
// of `user_data` so we're fine.
let closure: &RepoCheckoutFilter = from_glib_none(user_data);
// `repo` lives at least until the end of this function. This means we can just borrow the
// reference so long as our `repo` is not moved out of this function.
let repo = from_glib_borrow(repo);
// This is a copy so no problems here.
let path: PathBuf = from_glib_none(path);
let result = closure.call(&repo, &path, stat);
result.into_glib()
}
/// Unwind-safe trampoline to call the Rust filter callback. See [filter_trampoline](fn.filter_trampoline.html).
/// This function additionally catches panics and aborts to avoid unwinding into C code.
pub(super) unsafe extern "C" fn filter_trampoline_unwindsafe(
repo: *mut ffi::OstreeRepo,
path: *const c_char,
stat: *mut libc::stat,
user_data: gpointer,
) -> ffi::OstreeRepoCheckoutFilterResult {
// Unwinding across an FFI boundary is Undefined Behavior and we have no other way to communicate
// the error. We abort() safely to avoid further problems.
let result = catch_unwind(move || filter_trampoline(repo, path, stat, user_data));
result.unwrap_or_else(|panic| {
print_panic(panic);
abort()
})
}
/// Print a panic message and the value to stderr, if we can.
///
/// If the panic value is either `&str` or `String`, we print it. Otherwise, we don't.
fn print_panic(panic: Box<dyn Any>) {
eprintln!("A Rust callback invoked by C code panicked.");
eprintln!("Unwinding across FFI boundaries is Undefined Behavior so abort() will be called.");
let msg = {
if let Some(s) = panic.as_ref().downcast_ref::<&str>() {
s
} else if let Some(s) = panic.as_ref().downcast_ref::<String>() {
s
} else {
"UNABLE TO SHOW VALUE OF PANIC"
}
};
eprintln!("Panic value: {}", msg);
}
#[cfg(test)]
mod tests {
use super::*;
use std::ffi::CString;
use std::ptr;
#[test]
#[should_panic]
fn trampoline_should_panic_if_repo_is_nullptr() {
let path = CString::new("/a/b/c").unwrap();
let mut stat: libc::stat = unsafe { std::mem::zeroed() };
let filter = RepoCheckoutFilter(Box::new(|_, _, _| RepoCheckoutFilterResult::Allow));
unsafe {
filter_trampoline(
ptr::null_mut(),
path.as_ptr(),
&mut stat,
filter.to_glib_none().0,
);
}
}
#[test]
#[should_panic]
fn trampoline_should_panic_if_path_is_nullptr() {
let repo = Repo::new_default();
let mut stat: libc::stat = unsafe { std::mem::zeroed() };
let filter = RepoCheckoutFilter(Box::new(|_, _, _| RepoCheckoutFilterResult::Allow));
unsafe {
filter_trampoline(
repo.to_glib_none().0,
ptr::null(),
&mut stat,
filter.to_glib_none().0,
);
}
}
#[test]
#[should_panic]
fn trampoline_should_panic_if_stat_is_nullptr() {
let repo = Repo::new_default();
let path = CString::new("/a/b/c").unwrap();
let filter = RepoCheckoutFilter(Box::new(|_, _, _| RepoCheckoutFilterResult::Allow));
unsafe {
filter_trampoline(
repo.to_glib_none().0,
path.as_ptr(),
ptr::null_mut(),
filter.to_glib_none().0,
);
}
}
#[test]
#[should_panic]
fn trampoline_should_panic_if_user_data_is_nullptr() {
let repo = Repo::new_default();
let path = CString::new("/a/b/c").unwrap();
let mut stat: libc::stat = unsafe { std::mem::zeroed() };
unsafe {
filter_trampoline(
repo.to_glib_none().0,
path.as_ptr(),
&mut stat,
ptr::null_mut(),
);
}
}
#[test]
fn trampoline_should_call_the_closure() {
let repo = Repo::new_default();
let path = CString::new("/a/b/c").unwrap();
let mut stat: libc::stat = unsafe { std::mem::zeroed() };
let filter = {
let repo = repo.clone();
let path = path.clone();
RepoCheckoutFilter(Box::new(move |arg_repo, arg_path, _| {
assert_eq!(arg_repo, &repo);
assert_eq!(&CString::new(arg_path.to_str().unwrap()).unwrap(), &path);
RepoCheckoutFilterResult::Skip
}))
};
let result = unsafe {
filter_trampoline(
repo.to_glib_none().0,
path.as_ptr(),
&mut stat,
filter.to_glib_none().0,
)
};
assert_eq!(result, ffi::OSTREE_REPO_CHECKOUT_FILTER_SKIP);
}
}

View File

@ -0,0 +1,45 @@
glib::wrapper! {
/// A list of statistics for each transaction that may be interesting for reporting purposes.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct RepoTransactionStats(Boxed<ffi::OstreeRepoTransactionStats>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::ostree_repo_transaction_stats_get_type(), ptr as *mut _) as *mut ffi::OstreeRepoTransactionStats,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::ostree_repo_transaction_stats_get_type(), ptr as *mut _),
init => |_ptr| (),
clear => |_ptr| (),
type_ => || ffi::ostree_repo_transaction_stats_get_type(),
}
}
impl RepoTransactionStats {
/// The total number of metadata objects in the repository after this transaction has completed.
pub fn get_metadata_objects_total(&self) -> usize {
self.0.metadata_objects_total as usize
}
/// The number of metadata objects that were written to the repository in this transaction.
pub fn get_metadata_objects_written(&self) -> usize {
self.0.metadata_objects_written as usize
}
/// The total number of content objects in the repository after this transaction has completed.
pub fn get_content_objects_total(&self) -> usize {
self.0.content_objects_total as usize
}
/// The number of content objects that were written to the repository in this transaction.
pub fn get_content_objects_written(&self) -> usize {
self.0.content_objects_written as usize
}
/// The amount of data added to the repository, in bytes, counting only content objects.
pub fn get_content_bytes_written(&self) -> u64 {
self.0.content_bytes_written
}
/// The amount of cache hits during this transaction.
pub fn get_devino_cache_hits(&self) -> usize {
self.0.devino_cache_hits as usize
}
}

View File

@ -0,0 +1,11 @@
use crate::SePolicy;
use std::ptr;
impl SePolicy {
/// Reset the SELinux filesystem creation context.
pub fn fscreatecon_cleanup() {
unsafe {
ffi::ostree_sepolicy_fscreatecon_cleanup(ptr::null_mut());
}
}
}

View File

@ -0,0 +1,107 @@
use crate::gio;
use crate::Sysroot;
use std::path::PathBuf;
#[derive(Clone, Debug, Default)]
/// Builder object for `Sysroot`.
pub struct SysrootBuilder {
path: Option<PathBuf>,
mount_namespace_in_use: bool,
}
impl SysrootBuilder {
/// Create a new builder for `Sysroot`.
pub fn new() -> Self {
Self::default()
}
/// Set the path to the sysroot location.
pub fn path(mut self, path: Option<PathBuf>) -> Self {
self.path = path;
self
}
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
/// Set whether the logic is running in its own mount namespace.
pub fn mount_namespace_in_use(mut self, mount_namespace_in_use: bool) -> Self {
self.mount_namespace_in_use = mount_namespace_in_use;
self
}
/// Load an existing `Sysroot` from disk, finalizing this builder.
pub fn load(self, cancellable: Option<&gio::Cancellable>) -> Result<Sysroot, glib::Error> {
let sysroot = self.configure_common();
sysroot.load(cancellable)?;
Ok(sysroot)
}
/// Create a new `Sysroot` on disk, finalizing this builder.
pub fn create(self, cancellable: Option<&gio::Cancellable>) -> Result<Sysroot, glib::Error> {
let sysroot = self.configure_common();
sysroot.ensure_initialized(cancellable)?;
sysroot.load(cancellable)?;
Ok(sysroot)
}
/// Perform common configuration steps, returning a not-yet-fully-loaded `Sysroot`.
fn configure_common(self) -> Sysroot {
let sysroot = {
let opt_file = self.path.map(gio::File::for_path);
Sysroot::new(opt_file.as_ref())
};
#[cfg(feature = "v2020_1")]
if self.mount_namespace_in_use {
sysroot.set_mount_namespace_in_use();
}
sysroot
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_sysroot_create_load_empty() {
// Create and load an empty sysroot. Make sure it can be properly
// inspected as empty, without panics.
let tmpdir = tempfile::tempdir().unwrap();
let path_created = {
let tmp_path = Some(tmpdir.path().to_path_buf());
let builder = SysrootBuilder::new().path(tmp_path);
let sysroot = builder.create(gio::NONE_CANCELLABLE).unwrap();
assert!(sysroot.fd() >= 0);
assert_eq!(sysroot.deployments().len(), 0);
assert_eq!(sysroot.booted_deployment(), None);
assert_eq!(sysroot.bootversion(), 0);
assert_eq!(sysroot.subbootversion(), 0);
sysroot.cleanup(gio::NONE_CANCELLABLE).unwrap();
sysroot.path().unwrap()
};
let path_loaded = {
let tmp_path = Some(tmpdir.path().to_path_buf());
let builder = SysrootBuilder::new().path(tmp_path);
let sysroot = builder.create(gio::NONE_CANCELLABLE).unwrap();
assert!(sysroot.fd() >= 0);
assert_eq!(sysroot.deployments().len(), 0);
assert_eq!(sysroot.booted_deployment(), None);
assert_eq!(sysroot.bootversion(), 0);
assert_eq!(sysroot.subbootversion(), 0);
sysroot.cleanup(gio::NONE_CANCELLABLE).unwrap();
sysroot.path().unwrap()
};
assert_eq!(path_created.to_string(), path_loaded.to_string());
}
}

View File

@ -0,0 +1,101 @@
use ffi::OstreeSysrootDeployTreeOpts;
use glib::translate::*;
use libc::c_char;
/// Options for deploying an ostree commit.
pub struct SysrootDeployTreeOpts<'a> {
/// Use these kernel arguments.
pub override_kernel_argv: Option<&'a [&'a str]>,
/// Paths to initramfs files to overlay.
pub overlay_initrds: Option<&'a [&'a str]>,
}
impl<'a> Default for SysrootDeployTreeOpts<'a> {
fn default() -> Self {
SysrootDeployTreeOpts {
override_kernel_argv: None,
overlay_initrds: None,
}
}
}
type OptionStrSliceStorage<'a> =
<Option<&'a [&'a str]> as ToGlibPtr<'a, *mut *mut c_char>>::Storage;
impl<'a, 'b: 'a> ToGlibPtr<'a, *const OstreeSysrootDeployTreeOpts> for SysrootDeployTreeOpts<'b> {
type Storage = (
Box<OstreeSysrootDeployTreeOpts>,
OptionStrSliceStorage<'a>,
OptionStrSliceStorage<'a>,
);
fn to_glib_none(&'a self) -> Stash<*const OstreeSysrootDeployTreeOpts, Self> {
// Creating this struct from zeroed memory is fine since it's `repr(C)` and only contains
// primitive types. Zeroing it ensures we handle the unused bytes correctly.
// The struct needs to be boxed so the pointer we return remains valid even as the Stash is
// moved around.
let mut options = Box::new(unsafe { std::mem::zeroed::<OstreeSysrootDeployTreeOpts>() });
let override_kernel_argv = self.override_kernel_argv.to_glib_none();
let overlay_initrds = self.overlay_initrds.to_glib_none();
options.override_kernel_argv = override_kernel_argv.0;
options.overlay_initrds = overlay_initrds.0;
Stash(
options.as_ref(),
(options, override_kernel_argv.1, overlay_initrds.1),
)
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::{ffi::CStr, ptr::null_mut};
unsafe fn ptr_array_to_slice<'a, T>(ptr: *mut *mut T) -> &'a [*mut T] {
let mut len = 0;
while !(*ptr.offset(len)).is_null() {
len += 1;
}
std::slice::from_raw_parts(ptr, len as usize)
}
unsafe fn str_ptr_array_to_vec<'a>(ptr: *mut *mut c_char) -> Vec<&'a str> {
ptr_array_to_slice(ptr)
.iter()
.map(|x| CStr::from_ptr(*x).to_str().unwrap())
.collect()
}
#[test]
fn should_convert_default_options() {
let options = SysrootDeployTreeOpts::default();
let stash = options.to_glib_none();
let ptr = stash.0;
unsafe {
assert_eq!((*ptr).override_kernel_argv, null_mut());
assert_eq!((*ptr).overlay_initrds, null_mut());
}
}
#[test]
fn should_convert_non_default_options() {
let override_kernel_argv = vec!["quiet", "splash", "ro"];
let overlay_initrds = vec!["overlay1", "overlay2"];
let options = SysrootDeployTreeOpts {
override_kernel_argv: Some(&override_kernel_argv),
overlay_initrds: Some(&overlay_initrds),
};
let stash = options.to_glib_none();
let ptr = stash.0;
unsafe {
assert_eq!(
str_ptr_array_to_vec((*ptr).override_kernel_argv),
vec!["quiet", "splash", "ro"]
);
assert_eq!(
str_ptr_array_to_vec((*ptr).overlay_initrds),
vec!["overlay1", "overlay2"]
);
}
}
}

View File

@ -0,0 +1,57 @@
use ffi::OstreeSysrootWriteDeploymentsOpts;
use glib::translate::*;
/// Options for writing a deployment.
pub struct SysrootWriteDeploymentsOpts {
/// Perform cleanup after writing the deployment.
pub do_postclean: bool,
}
impl Default for SysrootWriteDeploymentsOpts {
fn default() -> Self {
SysrootWriteDeploymentsOpts {
do_postclean: false,
}
}
}
impl<'a> ToGlibPtr<'a, *const OstreeSysrootWriteDeploymentsOpts> for SysrootWriteDeploymentsOpts {
type Storage = Box<OstreeSysrootWriteDeploymentsOpts>;
fn to_glib_none(&'a self) -> Stash<*const OstreeSysrootWriteDeploymentsOpts, Self> {
// Creating this struct from zeroed memory is fine since it's `repr(C)` and only contains
// primitive types.
// The struct needs to be boxed so the pointer we return remains valid even as the Stash is
// moved around.
let mut options =
Box::new(unsafe { std::mem::zeroed::<OstreeSysrootWriteDeploymentsOpts>() });
options.do_postclean = self.do_postclean.into_glib();
Stash(options.as_ref(), options)
}
}
#[cfg(test)]
mod tests {
use super::*;
use glib::ffi::{GFALSE, GTRUE};
#[test]
fn should_convert_default_options() {
let options = SysrootWriteDeploymentsOpts::default();
let stash = options.to_glib_none();
let ptr = stash.0;
unsafe {
assert_eq!((*ptr).do_postclean, GFALSE);
}
}
#[test]
fn should_convert_non_default_options() {
let options = SysrootWriteDeploymentsOpts { do_postclean: true };
let stash = options.to_glib_none();
let ptr = stash.0;
unsafe {
assert_eq!((*ptr).do_postclean, GTRUE);
}
}
}

View File

@ -0,0 +1,79 @@
#![cfg(feature = "v2018_6")]
use crate::CollectionRef;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
fn hash(v: &impl Hash) -> u64 {
let mut s = DefaultHasher::new();
v.hash(&mut s);
s.finish()
}
#[test]
fn same_value_should_be_equal() {
let r = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
assert_eq!(r, r);
}
#[test]
fn equal_values_should_be_equal() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
assert_eq!(a, b);
}
#[test]
fn equal_values_without_collection_id_should_be_equal() {
let a = CollectionRef::new(None, "ref-name").unwrap();
let b = CollectionRef::new(None, "ref-name").unwrap();
assert_eq!(a, b);
}
#[test]
fn different_values_should_not_be_equal() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref1").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref2").unwrap();
assert_ne!(a, b);
}
#[test]
fn new_with_invalid_collection_id_should_return_none() {
let r = CollectionRef::new(Some(".abc"), "ref");
assert_eq!(r, None);
}
#[test]
fn hash_for_equal_values_should_be_equal() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
assert_eq!(hash(&a), hash(&b));
}
#[test]
fn hash_for_values_with_different_collection_id_should_be_different() {
let a = CollectionRef::new(Some("io.gitlab.fkrull1"), "ref").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull2"), "ref").unwrap();
assert_ne!(hash(&a), hash(&b));
}
#[test]
fn hash_for_values_with_different_ref_id_should_be_different() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-1").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-2").unwrap();
assert_ne!(hash(&a), hash(&b));
}
#[test]
fn hash_should_be_different_if_collection_id_is_absent() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = CollectionRef::new(None, "ref").unwrap();
assert_ne!(hash(&a), hash(&b));
}
#[test]
fn clone_should_be_equal_to_original_value() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = a.clone();
assert_eq!(a, b);
}

View File

@ -0,0 +1,64 @@
#![cfg(feature = "v2019_3")]
use crate::KernelArgs;
#[test]
fn should_create_and_fill_kernel_args() {
let mut args = KernelArgs::new();
args.append("key=value");
args.append("arg1");
args.append("key2=value2");
assert_eq!(args.to_string(), "key=value arg1 key2=value2");
}
#[test]
fn should_convert_to_string_vec() {
let mut args = KernelArgs::new();
args.parse_append("key=value arg1 key2=value2");
assert_eq!(
args.to_strv()
.iter()
.map(|s| s.as_str())
.collect::<Vec<_>>(),
vec!["key=value", "arg1", "key2=value2"]
);
}
#[test]
fn should_get_last_value() {
let mut args = KernelArgs::new();
args.append("key=value1");
args.append("key=value2");
args.append("key=value3");
assert_eq!(args.get_last_value("key").unwrap(), "value3");
}
#[test]
fn should_convert_from_string() {
let args = KernelArgs::from(String::from("arg1 arg2 arg3=value"));
assert_eq!(args.to_strv(), vec!["arg1", "arg2", "arg3=value"]);
}
#[test]
fn should_append_argv() {
let mut args = KernelArgs::new();
args.append_argv(&["arg1", "arg2=value", "arg3", "arg4=value"]);
assert_eq!(args.to_string(), "arg1 arg2=value arg3 arg4=value");
}
#[test]
fn should_append_argv_filtered() {
let mut args = KernelArgs::new();
args.append_argv_filtered(
&["prefix.arg1", "arg2", "prefix.arg3", "arg4=value"],
&["prefix"],
);
assert_eq!(args.to_string(), "arg2 arg4=value");
}
#[test]
fn should_replace_argv() {
let mut args = KernelArgs::from_string("arg1=value1 arg2=value2 arg3");
args.replace_argv(&["arg1=value3", "arg3=value4", "arg4"]);
assert_eq!(args.to_string(), "arg1=value3 arg2=value2 arg3=value4 arg4");
}

View File

@ -0,0 +1,3 @@
mod collection_ref;
mod kernel_args;
mod repo;

View File

@ -0,0 +1,14 @@
use crate::Repo;
use crate::RepoMode;
#[test]
fn should_get_repo_mode_from_string() {
let mode = Repo::mode_from_string("archive").unwrap();
assert_eq!(RepoMode::Archive, mode);
}
#[test]
fn should_return_error_for_invalid_repo_mode_string() {
let result = Repo::mode_from_string("invalid-repo-mode");
assert!(result.is_err());
}

View File

@ -0,0 +1,209 @@
[build-dependencies]
system-deps = "3"
[dependencies]
glib-sys = "0.14"
gobject-sys = "0.14"
gio-sys = "0.14"
libc = "0.2"
[dev-dependencies]
shell-words = "1.0.0"
tempfile = "3"
[features]
v2014_9 = []
v2015_7 = ["v2014_9"]
v2016_3 = ["v2015_7"]
v2016_4 = ["v2016_3"]
v2016_5 = ["v2016_4"]
v2016_6 = ["v2016_5"]
v2016_7 = ["v2016_6"]
v2016_8 = ["v2016_7"]
v2016_14 = ["v2016_8"]
v2017_1 = ["v2016_14"]
v2017_2 = ["v2017_1"]
v2017_3 = ["v2017_2"]
v2017_4 = ["v2017_3"]
v2017_6 = ["v2017_4"]
v2017_7 = ["v2017_6"]
v2017_8 = ["v2017_7"]
v2017_9 = ["v2017_8"]
v2017_10 = ["v2017_9"]
v2017_11 = ["v2017_10"]
v2017_12 = ["v2017_11"]
v2017_13 = ["v2017_12"]
v2017_15 = ["v2017_13"]
v2018_2 = ["v2017_15"]
v2018_3 = ["v2018_2"]
v2018_5 = ["v2018_3"]
v2018_6 = ["v2018_5"]
v2018_7 = ["v2018_6"]
v2018_9 = ["v2018_7"]
v2019_2 = ["v2018_9"]
v2019_3 = ["v2019_2"]
v2019_4 = ["v2019_3"]
v2019_6 = ["v2019_4"]
v2020_1 = ["v2019_6"]
v2020_2 = ["v2020_1"]
v2020_4 = ["v2020_2"]
dox = []
v2020_7 = ["v2020_4"]
v2020_8 = ["v2020_7"]
v2021_1 = ["v2020_8"]
v2021_2 = ["v2021_1"]
v2021_3 = ["v2021_2"]
v2021_4 = ["v2021_3"]
v2021_5 = ["v2021_4"]
v2022_2 = ["v2021_5"]
[lib]
name = "ostree_sys"
[package]
authors = ["Felix Krull"]
build = "build.rs"
categories = ["external-ffi-bindings"]
description = "FFI bindings to libostree-1"
documentation = "https://docs.rs/ostree-sys"
keywords = ["ffi", "ostree", "libostree"]
license = "MIT"
links = "ostree-1"
name = "ostree-sys"
repository = "https://github.com/ostreedev/ostree-rs"
version = "0.9.2"
edition = "2018"
[package.metadata.docs.rs]
features = ["dox"]
[package.metadata.system-deps.ostree_1]
name = "ostree-1"
version = "0.0"
[package.metadata.system-deps.ostree_1.v2014_9]
version = "2014.9"
[package.metadata.system-deps.ostree_1.v2015_7]
version = "2015.7"
[package.metadata.system-deps.ostree_1.v2016_3]
version = "2016.3"
[package.metadata.system-deps.ostree_1.v2016_4]
version = "2016.4"
[package.metadata.system-deps.ostree_1.v2016_5]
version = "2016.5"
[package.metadata.system-deps.ostree_1.v2016_6]
version = "2016.6"
[package.metadata.system-deps.ostree_1.v2016_7]
version = "2016.7"
[package.metadata.system-deps.ostree_1.v2016_8]
version = "2016.8"
[package.metadata.system-deps.ostree_1.v2016_14]
version = "2016.14"
[package.metadata.system-deps.ostree_1.v2017_1]
version = "2017.1"
[package.metadata.system-deps.ostree_1.v2017_2]
version = "2017.2"
[package.metadata.system-deps.ostree_1.v2017_3]
version = "2017.3"
[package.metadata.system-deps.ostree_1.v2017_4]
version = "2017.4"
[package.metadata.system-deps.ostree_1.v2017_6]
version = "2017.6"
[package.metadata.system-deps.ostree_1.v2017_7]
version = "2017.7"
[package.metadata.system-deps.ostree_1.v2017_8]
version = "2017.8"
[package.metadata.system-deps.ostree_1.v2017_9]
version = "2017.9"
[package.metadata.system-deps.ostree_1.v2017_10]
version = "2017.10"
[package.metadata.system-deps.ostree_1.v2017_11]
version = "2017.11"
[package.metadata.system-deps.ostree_1.v2017_12]
version = "2017.12"
[package.metadata.system-deps.ostree_1.v2017_13]
version = "2017.13"
[package.metadata.system-deps.ostree_1.v2017_15]
version = "2017.15"
[package.metadata.system-deps.ostree_1.v2018_2]
version = "2018.2"
[package.metadata.system-deps.ostree_1.v2018_3]
version = "2018.3"
[package.metadata.system-deps.ostree_1.v2018_5]
version = "2018.5"
[package.metadata.system-deps.ostree_1.v2018_6]
version = "2018.6"
[package.metadata.system-deps.ostree_1.v2018_7]
version = "2018.7"
[package.metadata.system-deps.ostree_1.v2018_9]
version = "2018.9"
[package.metadata.system-deps.ostree_1.v2019_2]
version = "2019.2"
[package.metadata.system-deps.ostree_1.v2019_3]
version = "2019.3"
[package.metadata.system-deps.ostree_1.v2019_4]
version = "2019.4"
[package.metadata.system-deps.ostree_1.v2019_6]
version = "2019.6"
[package.metadata.system-deps.ostree_1.v2020_1]
version = "2020.1"
[package.metadata.system-deps.ostree_1.v2020_2]
version = "2020.2"
[package.metadata.system-deps.ostree_1.v2020_4]
version = "2020.4"
[package.metadata.system-deps.ostree_1.v2020_7]
version = "2020.7"
[package.metadata.system-deps.ostree_1.v2020_8]
version = "2020.8"
[package.metadata.system-deps.ostree_1.v2021_1]
version = "2021.1"
[package.metadata.system-deps.ostree_1.v2021_2]
version = "2021.2"
[package.metadata.system-deps.ostree_1.v2021_3]
version = "2021.3"
[package.metadata.system-deps.ostree_1.v2021_4]
version = "2021.4"
[package.metadata.system-deps.ostree_1.v2021_5]
version = "2021.5"
[package.metadata.system-deps.ostree_1.v2022_2]
version = "2022.2"

21
rust-bindings/sys/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018, 2019, 2020 Felix Krull
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,17 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
#[cfg(not(feature = "dox"))]
use std::process;
#[cfg(feature = "dox")]
fn main() {} // prevent linking libraries to avoid documentation failure
#[cfg(not(feature = "dox"))]
fn main() {
if let Err(s) = system_deps::Config::new().probe() {
println!("cargo:warning={}", s);
process::exit(1);
}
}

View File

@ -0,0 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ e8f82cf6)
from gir-files

3788
rust-bindings/sys/src/lib.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
pub use libc::stat;

View File

@ -0,0 +1,793 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use ostree_sys::*;
use std::env;
use std::error::Error;
use std::ffi::OsString;
use std::mem::{align_of, size_of};
use std::path::Path;
use std::process::Command;
use std::str;
use tempfile::Builder;
static PACKAGES: &[&str] = &["ostree-1"];
#[derive(Clone, Debug)]
struct Compiler {
pub args: Vec<String>,
}
impl Compiler {
pub fn new() -> Result<Self, Box<dyn Error>> {
let mut args = get_var("CC", "cc")?;
args.push("-Wno-deprecated-declarations".to_owned());
// For _Generic
args.push("-std=c11".to_owned());
// For %z support in printf when using MinGW.
args.push("-D__USE_MINGW_ANSI_STDIO".to_owned());
args.extend(get_var("CFLAGS", "")?);
args.extend(get_var("CPPFLAGS", "")?);
args.extend(pkg_config_cflags(PACKAGES)?);
Ok(Self { args })
}
pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box<dyn Error>> {
let mut cmd = self.to_command();
cmd.arg(src);
cmd.arg("-o");
cmd.arg(out);
let status = cmd.spawn()?.wait()?;
if !status.success() {
return Err(format!("compilation command {:?} failed, {}", &cmd, status).into());
}
Ok(())
}
fn to_command(&self) -> Command {
let mut cmd = Command::new(&self.args[0]);
cmd.args(&self.args[1..]);
cmd
}
}
fn get_var(name: &str, default: &str) -> Result<Vec<String>, Box<dyn Error>> {
match env::var(name) {
Ok(value) => Ok(shell_words::split(&value)?),
Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?),
Err(err) => Err(format!("{} {}", name, err).into()),
}
}
fn pkg_config_cflags(packages: &[&str]) -> Result<Vec<String>, Box<dyn Error>> {
if packages.is_empty() {
return Ok(Vec::new());
}
let pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config"));
let mut cmd = Command::new(pkg_config);
cmd.arg("--cflags");
cmd.args(packages);
let out = cmd.output()?;
if !out.status.success() {
return Err(format!("command {:?} returned {}", &cmd, out.status).into());
}
let stdout = str::from_utf8(&out.stdout)?;
Ok(shell_words::split(stdout.trim())?)
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
struct Layout {
size: usize,
alignment: usize,
}
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
struct Results {
/// Number of successfully completed tests.
passed: usize,
/// Total number of failed tests (including those that failed to compile).
failed: usize,
}
impl Results {
fn record_passed(&mut self) {
self.passed += 1;
}
fn record_failed(&mut self) {
self.failed += 1;
}
fn summary(&self) -> String {
format!("{} passed; {} failed", self.passed, self.failed)
}
fn expect_total_success(&self) {
if self.failed == 0 {
println!("OK: {}", self.summary());
} else {
panic!("FAILED: {}", self.summary());
};
}
}
#[test]
fn cross_validate_constants_with_c() {
let mut c_constants: Vec<(String, String)> = Vec::new();
for l in get_c_output("constant").unwrap().lines() {
let mut words = l.trim().split(';');
let name = words.next().expect("Failed to parse name").to_owned();
let value = words
.next()
.and_then(|s| s.parse().ok())
.expect("Failed to parse value");
c_constants.push((name, value));
}
let mut results = Results::default();
for ((rust_name, rust_value), (c_name, c_value)) in
RUST_CONSTANTS.iter().zip(c_constants.iter())
{
if rust_name != c_name {
results.record_failed();
eprintln!("Name mismatch:\nRust: {:?}\nC: {:?}", rust_name, c_name,);
continue;
}
if rust_value != c_value {
results.record_failed();
eprintln!(
"Constant value mismatch for {}\nRust: {:?}\nC: {:?}",
rust_name, rust_value, &c_value
);
continue;
}
results.record_passed();
}
results.expect_total_success();
}
#[test]
fn cross_validate_layout_with_c() {
let mut c_layouts = Vec::new();
for l in get_c_output("layout").unwrap().lines() {
let mut words = l.trim().split(';');
let name = words.next().expect("Failed to parse name").to_owned();
let size = words
.next()
.and_then(|s| s.parse().ok())
.expect("Failed to parse size");
let alignment = words
.next()
.and_then(|s| s.parse().ok())
.expect("Failed to parse alignment");
c_layouts.push((name, Layout { size, alignment }));
}
let mut results = Results::default();
for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter())
{
if rust_name != c_name {
results.record_failed();
eprintln!("Name mismatch:\nRust: {:?}\nC: {:?}", rust_name, c_name,);
continue;
}
if rust_layout != c_layout {
results.record_failed();
eprintln!(
"Layout mismatch for {}\nRust: {:?}\nC: {:?}",
rust_name, rust_layout, &c_layout
);
continue;
}
results.record_passed();
}
results.expect_total_success();
}
fn get_c_output(name: &str) -> Result<String, Box<dyn Error>> {
let tmpdir = Builder::new().prefix("abi").tempdir()?;
let exe = tmpdir.path().join(name);
let c_file = Path::new("tests").join(name).with_extension("c");
let cc = Compiler::new().expect("configured compiler");
cc.compile(&c_file, &exe)?;
let mut abi_cmd = Command::new(exe);
let output = abi_cmd.output()?;
if !output.status.success() {
return Err(format!("command {:?} failed, {:?}", &abi_cmd, &output).into());
}
Ok(String::from_utf8(output.stdout)?)
}
const RUST_LAYOUTS: &[(&str, Layout)] = &[
(
"OstreeAsyncProgressClass",
Layout {
size: size_of::<OstreeAsyncProgressClass>(),
alignment: align_of::<OstreeAsyncProgressClass>(),
},
),
(
"OstreeChecksumFlags",
Layout {
size: size_of::<OstreeChecksumFlags>(),
alignment: align_of::<OstreeChecksumFlags>(),
},
),
(
"OstreeCollectionRef",
Layout {
size: size_of::<OstreeCollectionRef>(),
alignment: align_of::<OstreeCollectionRef>(),
},
),
(
"OstreeCollectionRefv",
Layout {
size: size_of::<OstreeCollectionRefv>(),
alignment: align_of::<OstreeCollectionRefv>(),
},
),
(
"OstreeCommitSizesEntry",
Layout {
size: size_of::<OstreeCommitSizesEntry>(),
alignment: align_of::<OstreeCommitSizesEntry>(),
},
),
(
"OstreeContentWriterClass",
Layout {
size: size_of::<OstreeContentWriterClass>(),
alignment: align_of::<OstreeContentWriterClass>(),
},
),
(
"OstreeDeploymentUnlockedState",
Layout {
size: size_of::<OstreeDeploymentUnlockedState>(),
alignment: align_of::<OstreeDeploymentUnlockedState>(),
},
),
(
"OstreeDiffDirsOptions",
Layout {
size: size_of::<OstreeDiffDirsOptions>(),
alignment: align_of::<OstreeDiffDirsOptions>(),
},
),
(
"OstreeDiffFlags",
Layout {
size: size_of::<OstreeDiffFlags>(),
alignment: align_of::<OstreeDiffFlags>(),
},
),
(
"OstreeDiffItem",
Layout {
size: size_of::<OstreeDiffItem>(),
alignment: align_of::<OstreeDiffItem>(),
},
),
(
"OstreeGpgError",
Layout {
size: size_of::<OstreeGpgError>(),
alignment: align_of::<OstreeGpgError>(),
},
),
(
"OstreeGpgSignatureAttr",
Layout {
size: size_of::<OstreeGpgSignatureAttr>(),
alignment: align_of::<OstreeGpgSignatureAttr>(),
},
),
(
"OstreeGpgSignatureFormatFlags",
Layout {
size: size_of::<OstreeGpgSignatureFormatFlags>(),
alignment: align_of::<OstreeGpgSignatureFormatFlags>(),
},
),
(
"OstreeMutableTreeClass",
Layout {
size: size_of::<OstreeMutableTreeClass>(),
alignment: align_of::<OstreeMutableTreeClass>(),
},
),
(
"OstreeMutableTreeIter",
Layout {
size: size_of::<OstreeMutableTreeIter>(),
alignment: align_of::<OstreeMutableTreeIter>(),
},
),
(
"OstreeObjectType",
Layout {
size: size_of::<OstreeObjectType>(),
alignment: align_of::<OstreeObjectType>(),
},
),
(
"OstreeRepoCheckoutAtOptions",
Layout {
size: size_of::<OstreeRepoCheckoutAtOptions>(),
alignment: align_of::<OstreeRepoCheckoutAtOptions>(),
},
),
(
"OstreeRepoCheckoutFilterResult",
Layout {
size: size_of::<OstreeRepoCheckoutFilterResult>(),
alignment: align_of::<OstreeRepoCheckoutFilterResult>(),
},
),
(
"OstreeRepoCheckoutMode",
Layout {
size: size_of::<OstreeRepoCheckoutMode>(),
alignment: align_of::<OstreeRepoCheckoutMode>(),
},
),
(
"OstreeRepoCheckoutOverwriteMode",
Layout {
size: size_of::<OstreeRepoCheckoutOverwriteMode>(),
alignment: align_of::<OstreeRepoCheckoutOverwriteMode>(),
},
),
(
"OstreeRepoCommitFilterResult",
Layout {
size: size_of::<OstreeRepoCommitFilterResult>(),
alignment: align_of::<OstreeRepoCommitFilterResult>(),
},
),
(
"OstreeRepoCommitIterResult",
Layout {
size: size_of::<OstreeRepoCommitIterResult>(),
alignment: align_of::<OstreeRepoCommitIterResult>(),
},
),
(
"OstreeRepoCommitModifierFlags",
Layout {
size: size_of::<OstreeRepoCommitModifierFlags>(),
alignment: align_of::<OstreeRepoCommitModifierFlags>(),
},
),
(
"OstreeRepoCommitState",
Layout {
size: size_of::<OstreeRepoCommitState>(),
alignment: align_of::<OstreeRepoCommitState>(),
},
),
(
"OstreeRepoCommitTraverseFlags",
Layout {
size: size_of::<OstreeRepoCommitTraverseFlags>(),
alignment: align_of::<OstreeRepoCommitTraverseFlags>(),
},
),
(
"OstreeRepoCommitTraverseIter",
Layout {
size: size_of::<OstreeRepoCommitTraverseIter>(),
alignment: align_of::<OstreeRepoCommitTraverseIter>(),
},
),
(
"OstreeRepoFileClass",
Layout {
size: size_of::<OstreeRepoFileClass>(),
alignment: align_of::<OstreeRepoFileClass>(),
},
),
(
"OstreeRepoFinderAvahiClass",
Layout {
size: size_of::<OstreeRepoFinderAvahiClass>(),
alignment: align_of::<OstreeRepoFinderAvahiClass>(),
},
),
(
"OstreeRepoFinderConfigClass",
Layout {
size: size_of::<OstreeRepoFinderConfigClass>(),
alignment: align_of::<OstreeRepoFinderConfigClass>(),
},
),
(
"OstreeRepoFinderInterface",
Layout {
size: size_of::<OstreeRepoFinderInterface>(),
alignment: align_of::<OstreeRepoFinderInterface>(),
},
),
(
"OstreeRepoFinderMountClass",
Layout {
size: size_of::<OstreeRepoFinderMountClass>(),
alignment: align_of::<OstreeRepoFinderMountClass>(),
},
),
(
"OstreeRepoFinderOverrideClass",
Layout {
size: size_of::<OstreeRepoFinderOverrideClass>(),
alignment: align_of::<OstreeRepoFinderOverrideClass>(),
},
),
(
"OstreeRepoFinderResult",
Layout {
size: size_of::<OstreeRepoFinderResult>(),
alignment: align_of::<OstreeRepoFinderResult>(),
},
),
(
"OstreeRepoFinderResultv",
Layout {
size: size_of::<OstreeRepoFinderResultv>(),
alignment: align_of::<OstreeRepoFinderResultv>(),
},
),
(
"OstreeRepoListObjectsFlags",
Layout {
size: size_of::<OstreeRepoListObjectsFlags>(),
alignment: align_of::<OstreeRepoListObjectsFlags>(),
},
),
(
"OstreeRepoListRefsExtFlags",
Layout {
size: size_of::<OstreeRepoListRefsExtFlags>(),
alignment: align_of::<OstreeRepoListRefsExtFlags>(),
},
),
(
"OstreeRepoLockType",
Layout {
size: size_of::<OstreeRepoLockType>(),
alignment: align_of::<OstreeRepoLockType>(),
},
),
(
"OstreeRepoMode",
Layout {
size: size_of::<OstreeRepoMode>(),
alignment: align_of::<OstreeRepoMode>(),
},
),
(
"OstreeRepoPruneFlags",
Layout {
size: size_of::<OstreeRepoPruneFlags>(),
alignment: align_of::<OstreeRepoPruneFlags>(),
},
),
(
"OstreeRepoPruneOptions",
Layout {
size: size_of::<OstreeRepoPruneOptions>(),
alignment: align_of::<OstreeRepoPruneOptions>(),
},
),
(
"OstreeRepoPullFlags",
Layout {
size: size_of::<OstreeRepoPullFlags>(),
alignment: align_of::<OstreeRepoPullFlags>(),
},
),
(
"OstreeRepoRemoteChange",
Layout {
size: size_of::<OstreeRepoRemoteChange>(),
alignment: align_of::<OstreeRepoRemoteChange>(),
},
),
(
"OstreeRepoResolveRevExtFlags",
Layout {
size: size_of::<OstreeRepoResolveRevExtFlags>(),
alignment: align_of::<OstreeRepoResolveRevExtFlags>(),
},
),
(
"OstreeRepoTransactionStats",
Layout {
size: size_of::<OstreeRepoTransactionStats>(),
alignment: align_of::<OstreeRepoTransactionStats>(),
},
),
(
"OstreeRepoVerifyFlags",
Layout {
size: size_of::<OstreeRepoVerifyFlags>(),
alignment: align_of::<OstreeRepoVerifyFlags>(),
},
),
(
"OstreeSePolicyRestoreconFlags",
Layout {
size: size_of::<OstreeSePolicyRestoreconFlags>(),
alignment: align_of::<OstreeSePolicyRestoreconFlags>(),
},
),
(
"OstreeSignInterface",
Layout {
size: size_of::<OstreeSignInterface>(),
alignment: align_of::<OstreeSignInterface>(),
},
),
(
"OstreeStaticDeltaGenerateOpt",
Layout {
size: size_of::<OstreeStaticDeltaGenerateOpt>(),
alignment: align_of::<OstreeStaticDeltaGenerateOpt>(),
},
),
(
"OstreeStaticDeltaIndexFlags",
Layout {
size: size_of::<OstreeStaticDeltaIndexFlags>(),
alignment: align_of::<OstreeStaticDeltaIndexFlags>(),
},
),
(
"OstreeSysrootDeployTreeOpts",
Layout {
size: size_of::<OstreeSysrootDeployTreeOpts>(),
alignment: align_of::<OstreeSysrootDeployTreeOpts>(),
},
),
(
"OstreeSysrootSimpleWriteDeploymentFlags",
Layout {
size: size_of::<OstreeSysrootSimpleWriteDeploymentFlags>(),
alignment: align_of::<OstreeSysrootSimpleWriteDeploymentFlags>(),
},
),
(
"OstreeSysrootUpgraderFlags",
Layout {
size: size_of::<OstreeSysrootUpgraderFlags>(),
alignment: align_of::<OstreeSysrootUpgraderFlags>(),
},
),
(
"OstreeSysrootUpgraderPullFlags",
Layout {
size: size_of::<OstreeSysrootUpgraderPullFlags>(),
alignment: align_of::<OstreeSysrootUpgraderPullFlags>(),
},
),
(
"OstreeSysrootWriteDeploymentsOpts",
Layout {
size: size_of::<OstreeSysrootWriteDeploymentsOpts>(),
alignment: align_of::<OstreeSysrootWriteDeploymentsOpts>(),
},
),
];
const RUST_CONSTANTS: &[(&str, &str)] = &[
("(guint) OSTREE_CHECKSUM_FLAGS_CANONICAL_PERMISSIONS", "2"),
("(guint) OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS", "1"),
("(guint) OSTREE_CHECKSUM_FLAGS_NONE", "0"),
("OSTREE_COMMIT_GVARIANT_STRING", "(a{sv}aya(say)sstayay)"),
("OSTREE_COMMIT_META_KEY_ARCHITECTURE", "ostree.architecture"),
(
"OSTREE_COMMIT_META_KEY_COLLECTION_BINDING",
"ostree.collection-binding",
),
("OSTREE_COMMIT_META_KEY_ENDOFLIFE", "ostree.endoflife"),
(
"OSTREE_COMMIT_META_KEY_ENDOFLIFE_REBASE",
"ostree.endoflife-rebase",
),
("OSTREE_COMMIT_META_KEY_REF_BINDING", "ostree.ref-binding"),
("OSTREE_COMMIT_META_KEY_SOURCE_TITLE", "ostree.source-title"),
("OSTREE_COMMIT_META_KEY_VERSION", "version"),
("(gint) OSTREE_DEPLOYMENT_UNLOCKED_DEVELOPMENT", "1"),
("(gint) OSTREE_DEPLOYMENT_UNLOCKED_HOTFIX", "2"),
("(gint) OSTREE_DEPLOYMENT_UNLOCKED_NONE", "0"),
("(gint) OSTREE_DEPLOYMENT_UNLOCKED_TRANSIENT", "3"),
("(guint) OSTREE_DIFF_FLAGS_IGNORE_XATTRS", "1"),
("(guint) OSTREE_DIFF_FLAGS_NONE", "0"),
("OSTREE_DIRMETA_GVARIANT_STRING", "(uuua(ayay))"),
("OSTREE_FILEMETA_GVARIANT_STRING", "(uuua(ayay))"),
("(gint) OSTREE_GPG_ERROR_EXPIRED_KEY", "4"),
("(gint) OSTREE_GPG_ERROR_EXPIRED_SIGNATURE", "3"),
("(gint) OSTREE_GPG_ERROR_INVALID_SIGNATURE", "1"),
("(gint) OSTREE_GPG_ERROR_MISSING_KEY", "2"),
("(gint) OSTREE_GPG_ERROR_NO_SIGNATURE", "0"),
("(gint) OSTREE_GPG_ERROR_REVOKED_KEY", "5"),
("OSTREE_GPG_KEY_GVARIANT_STRING", "(aa{sv}aa{sv}a{sv})"),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_EXP_TIMESTAMP", "7"),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT", "5"),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT_PRIMARY", "12"),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_HASH_ALGO_NAME", "9"),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_KEY_EXPIRED", "2"),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP", "13"),
(
"(gint) OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY",
"14",
),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING", "4"),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_KEY_REVOKED", "3"),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_PUBKEY_ALGO_NAME", "8"),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED", "1"),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_TIMESTAMP", "6"),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL", "11"),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_USER_NAME", "10"),
("(gint) OSTREE_GPG_SIGNATURE_ATTR_VALID", "0"),
("(guint) OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT", "0"),
("OSTREE_MAX_METADATA_SIZE", "10485760"),
("OSTREE_MAX_METADATA_WARN_SIZE", "7340032"),
("OSTREE_METADATA_KEY_BOOTABLE", "ostree.bootable"),
("OSTREE_METADATA_KEY_LINUX", "ostree.linux"),
(
"OSTREE_META_KEY_DEPLOY_COLLECTION_ID",
"ostree.deploy-collection-id",
),
("(gint) OSTREE_OBJECT_TYPE_COMMIT", "4"),
("(gint) OSTREE_OBJECT_TYPE_COMMIT_META", "6"),
("(gint) OSTREE_OBJECT_TYPE_DIR_META", "3"),
("(gint) OSTREE_OBJECT_TYPE_DIR_TREE", "2"),
("(gint) OSTREE_OBJECT_TYPE_FILE", "1"),
("(gint) OSTREE_OBJECT_TYPE_FILE_XATTRS", "8"),
("(gint) OSTREE_OBJECT_TYPE_FILE_XATTRS_LINK", "9"),
("(gint) OSTREE_OBJECT_TYPE_PAYLOAD_LINK", "7"),
("(gint) OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT", "5"),
("OSTREE_ORIGIN_TRANSIENT_GROUP", "libostree-transient"),
("OSTREE_PATH_BOOTED", "/run/ostree-booted"),
("(gint) OSTREE_REPO_CHECKOUT_FILTER_ALLOW", "0"),
("(gint) OSTREE_REPO_CHECKOUT_FILTER_SKIP", "1"),
("(gint) OSTREE_REPO_CHECKOUT_MODE_NONE", "0"),
("(gint) OSTREE_REPO_CHECKOUT_MODE_USER", "1"),
("(gint) OSTREE_REPO_CHECKOUT_OVERWRITE_ADD_FILES", "2"),
("(gint) OSTREE_REPO_CHECKOUT_OVERWRITE_NONE", "0"),
("(gint) OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES", "1"),
("(gint) OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL", "3"),
("(gint) OSTREE_REPO_COMMIT_FILTER_ALLOW", "0"),
("(gint) OSTREE_REPO_COMMIT_FILTER_SKIP", "1"),
("(gint) OSTREE_REPO_COMMIT_ITER_RESULT_DIR", "3"),
("(gint) OSTREE_REPO_COMMIT_ITER_RESULT_END", "1"),
("(gint) OSTREE_REPO_COMMIT_ITER_RESULT_ERROR", "0"),
("(gint) OSTREE_REPO_COMMIT_ITER_RESULT_FILE", "2"),
(
"(guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS",
"4",
),
("(guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME", "16"),
(
"(guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_DEVINO_CANONICAL",
"32",
),
(
"(guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_ERROR_ON_UNLABELED",
"8",
),
(
"(guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES",
"2",
),
("(guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE", "0"),
("(guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS", "1"),
("(guint) OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL", "2"),
("(guint) OSTREE_REPO_COMMIT_STATE_NORMAL", "0"),
("(guint) OSTREE_REPO_COMMIT_STATE_PARTIAL", "1"),
("(guint) OSTREE_REPO_COMMIT_TRAVERSE_FLAG_COMMIT_ONLY", "2"),
("(guint) OSTREE_REPO_COMMIT_TRAVERSE_FLAG_NONE", "1"),
("(guint) OSTREE_REPO_LIST_OBJECTS_ALL", "4"),
("(guint) OSTREE_REPO_LIST_OBJECTS_LOOSE", "1"),
("(guint) OSTREE_REPO_LIST_OBJECTS_NO_PARENTS", "8"),
("(guint) OSTREE_REPO_LIST_OBJECTS_PACKED", "2"),
("(guint) OSTREE_REPO_LIST_REFS_EXT_ALIASES", "1"),
("(guint) OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS", "4"),
("(guint) OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES", "2"),
("(guint) OSTREE_REPO_LIST_REFS_EXT_NONE", "0"),
("(gint) OSTREE_REPO_LOCK_EXCLUSIVE", "1"),
("(gint) OSTREE_REPO_LOCK_SHARED", "0"),
("OSTREE_REPO_METADATA_REF", "ostree-metadata"),
("(gint) OSTREE_REPO_MODE_ARCHIVE", "1"),
("(gint) OSTREE_REPO_MODE_ARCHIVE_Z2", "1"),
("(gint) OSTREE_REPO_MODE_BARE", "0"),
("(gint) OSTREE_REPO_MODE_BARE_SPLIT_XATTRS", "4"),
("(gint) OSTREE_REPO_MODE_BARE_USER", "2"),
("(gint) OSTREE_REPO_MODE_BARE_USER_ONLY", "3"),
("(guint) OSTREE_REPO_PRUNE_FLAGS_COMMIT_ONLY", "4"),
("(guint) OSTREE_REPO_PRUNE_FLAGS_NONE", "0"),
("(guint) OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE", "1"),
("(guint) OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY", "2"),
("(guint) OSTREE_REPO_PULL_FLAGS_BAREUSERONLY_FILES", "8"),
("(guint) OSTREE_REPO_PULL_FLAGS_COMMIT_ONLY", "2"),
("(guint) OSTREE_REPO_PULL_FLAGS_MIRROR", "1"),
("(guint) OSTREE_REPO_PULL_FLAGS_NONE", "0"),
("(guint) OSTREE_REPO_PULL_FLAGS_TRUSTED_HTTP", "16"),
("(guint) OSTREE_REPO_PULL_FLAGS_UNTRUSTED", "4"),
("(gint) OSTREE_REPO_REMOTE_CHANGE_ADD", "0"),
("(gint) OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS", "1"),
("(gint) OSTREE_REPO_REMOTE_CHANGE_DELETE", "2"),
("(gint) OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS", "3"),
("(gint) OSTREE_REPO_REMOTE_CHANGE_REPLACE", "4"),
("(guint) OSTREE_REPO_RESOLVE_REV_EXT_LOCAL_ONLY", "1"),
("(guint) OSTREE_REPO_RESOLVE_REV_EXT_NONE", "0"),
("(guint) OSTREE_REPO_VERIFY_FLAGS_NONE", "0"),
("(guint) OSTREE_REPO_VERIFY_FLAGS_NO_GPG", "1"),
("(guint) OSTREE_REPO_VERIFY_FLAGS_NO_SIGNAPI", "2"),
(
"(guint) OSTREE_SEPOLICY_RESTORECON_FLAGS_ALLOW_NOLABEL",
"1",
),
(
"(guint) OSTREE_SEPOLICY_RESTORECON_FLAGS_KEEP_EXISTING",
"2",
),
("(guint) OSTREE_SEPOLICY_RESTORECON_FLAGS_NONE", "0"),
("OSTREE_SHA256_DIGEST_LEN", "32"),
("OSTREE_SHA256_STRING_LEN", "64"),
("OSTREE_SIGN_NAME_ED25519", "ed25519"),
("(gint) OSTREE_STATIC_DELTA_GENERATE_OPT_LOWLATENCY", "0"),
("(gint) OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR", "1"),
("(gint) OSTREE_STATIC_DELTA_INDEX_FLAGS_NONE", "0"),
("OSTREE_SUMMARY_GVARIANT_STRING", "(a(s(taya{sv}))a{sv})"),
("OSTREE_SUMMARY_SIG_GVARIANT_STRING", "a{sv}"),
(
"(guint) OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NONE",
"0",
),
(
"(guint) OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NOT_DEFAULT",
"2",
),
(
"(guint) OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN",
"4",
),
(
"(guint) OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN",
"1",
),
(
"(guint) OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_PENDING",
"8",
),
(
"(guint) OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_ROLLBACK",
"16",
),
(
"(guint) OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED",
"2",
),
("(guint) OSTREE_SYSROOT_UPGRADER_FLAGS_STAGE", "4"),
(
"(guint) OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_ALLOW_OLDER",
"1",
),
("(guint) OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_NONE", "0"),
("(guint) OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_SYNTHETIC", "2"),
("OSTREE_TIMESTAMP", "0"),
("OSTREE_TREE_GVARIANT_STRING", "(a(say)a(sayay))"),
];

View File

@ -0,0 +1,177 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
#include "manual.h"
#include <stdio.h>
#define PRINT_CONSTANT(CONSTANT_NAME) \
printf("%s;", #CONSTANT_NAME); \
printf(_Generic((CONSTANT_NAME), \
char *: "%s", \
const char *: "%s", \
char: "%c", \
signed char: "%hhd", \
unsigned char: "%hhu", \
short int: "%hd", \
unsigned short int: "%hu", \
int: "%d", \
unsigned int: "%u", \
long: "%ld", \
unsigned long: "%lu", \
long long: "%lld", \
unsigned long long: "%llu", \
float: "%f", \
double: "%f", \
long double: "%ld"), \
CONSTANT_NAME); \
printf("\n");
int main() {
PRINT_CONSTANT((guint) OSTREE_CHECKSUM_FLAGS_CANONICAL_PERMISSIONS);
PRINT_CONSTANT((guint) OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS);
PRINT_CONSTANT((guint) OSTREE_CHECKSUM_FLAGS_NONE);
PRINT_CONSTANT(OSTREE_COMMIT_GVARIANT_STRING);
PRINT_CONSTANT(OSTREE_COMMIT_META_KEY_ARCHITECTURE);
PRINT_CONSTANT(OSTREE_COMMIT_META_KEY_COLLECTION_BINDING);
PRINT_CONSTANT(OSTREE_COMMIT_META_KEY_ENDOFLIFE);
PRINT_CONSTANT(OSTREE_COMMIT_META_KEY_ENDOFLIFE_REBASE);
PRINT_CONSTANT(OSTREE_COMMIT_META_KEY_REF_BINDING);
PRINT_CONSTANT(OSTREE_COMMIT_META_KEY_SOURCE_TITLE);
PRINT_CONSTANT(OSTREE_COMMIT_META_KEY_VERSION);
PRINT_CONSTANT((gint) OSTREE_DEPLOYMENT_UNLOCKED_DEVELOPMENT);
PRINT_CONSTANT((gint) OSTREE_DEPLOYMENT_UNLOCKED_HOTFIX);
PRINT_CONSTANT((gint) OSTREE_DEPLOYMENT_UNLOCKED_NONE);
PRINT_CONSTANT((gint) OSTREE_DEPLOYMENT_UNLOCKED_TRANSIENT);
PRINT_CONSTANT((guint) OSTREE_DIFF_FLAGS_IGNORE_XATTRS);
PRINT_CONSTANT((guint) OSTREE_DIFF_FLAGS_NONE);
PRINT_CONSTANT(OSTREE_DIRMETA_GVARIANT_STRING);
PRINT_CONSTANT(OSTREE_FILEMETA_GVARIANT_STRING);
PRINT_CONSTANT((gint) OSTREE_GPG_ERROR_EXPIRED_KEY);
PRINT_CONSTANT((gint) OSTREE_GPG_ERROR_EXPIRED_SIGNATURE);
PRINT_CONSTANT((gint) OSTREE_GPG_ERROR_INVALID_SIGNATURE);
PRINT_CONSTANT((gint) OSTREE_GPG_ERROR_MISSING_KEY);
PRINT_CONSTANT((gint) OSTREE_GPG_ERROR_NO_SIGNATURE);
PRINT_CONSTANT((gint) OSTREE_GPG_ERROR_REVOKED_KEY);
PRINT_CONSTANT(OSTREE_GPG_KEY_GVARIANT_STRING);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_EXP_TIMESTAMP);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT_PRIMARY);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_HASH_ALGO_NAME);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_KEY_EXPIRED);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_KEY_REVOKED);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_PUBKEY_ALGO_NAME);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_TIMESTAMP);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_USER_NAME);
PRINT_CONSTANT((gint) OSTREE_GPG_SIGNATURE_ATTR_VALID);
PRINT_CONSTANT((guint) OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT);
PRINT_CONSTANT(OSTREE_MAX_METADATA_SIZE);
PRINT_CONSTANT(OSTREE_MAX_METADATA_WARN_SIZE);
PRINT_CONSTANT(OSTREE_METADATA_KEY_BOOTABLE);
PRINT_CONSTANT(OSTREE_METADATA_KEY_LINUX);
PRINT_CONSTANT(OSTREE_META_KEY_DEPLOY_COLLECTION_ID);
PRINT_CONSTANT((gint) OSTREE_OBJECT_TYPE_COMMIT);
PRINT_CONSTANT((gint) OSTREE_OBJECT_TYPE_COMMIT_META);
PRINT_CONSTANT((gint) OSTREE_OBJECT_TYPE_DIR_META);
PRINT_CONSTANT((gint) OSTREE_OBJECT_TYPE_DIR_TREE);
PRINT_CONSTANT((gint) OSTREE_OBJECT_TYPE_FILE);
PRINT_CONSTANT((gint) OSTREE_OBJECT_TYPE_FILE_XATTRS);
PRINT_CONSTANT((gint) OSTREE_OBJECT_TYPE_FILE_XATTRS_LINK);
PRINT_CONSTANT((gint) OSTREE_OBJECT_TYPE_PAYLOAD_LINK);
PRINT_CONSTANT((gint) OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT);
PRINT_CONSTANT(OSTREE_ORIGIN_TRANSIENT_GROUP);
PRINT_CONSTANT(OSTREE_PATH_BOOTED);
PRINT_CONSTANT((gint) OSTREE_REPO_CHECKOUT_FILTER_ALLOW);
PRINT_CONSTANT((gint) OSTREE_REPO_CHECKOUT_FILTER_SKIP);
PRINT_CONSTANT((gint) OSTREE_REPO_CHECKOUT_MODE_NONE);
PRINT_CONSTANT((gint) OSTREE_REPO_CHECKOUT_MODE_USER);
PRINT_CONSTANT((gint) OSTREE_REPO_CHECKOUT_OVERWRITE_ADD_FILES);
PRINT_CONSTANT((gint) OSTREE_REPO_CHECKOUT_OVERWRITE_NONE);
PRINT_CONSTANT((gint) OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES);
PRINT_CONSTANT((gint) OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL);
PRINT_CONSTANT((gint) OSTREE_REPO_COMMIT_FILTER_ALLOW);
PRINT_CONSTANT((gint) OSTREE_REPO_COMMIT_FILTER_SKIP);
PRINT_CONSTANT((gint) OSTREE_REPO_COMMIT_ITER_RESULT_DIR);
PRINT_CONSTANT((gint) OSTREE_REPO_COMMIT_ITER_RESULT_END);
PRINT_CONSTANT((gint) OSTREE_REPO_COMMIT_ITER_RESULT_ERROR);
PRINT_CONSTANT((gint) OSTREE_REPO_COMMIT_ITER_RESULT_FILE);
PRINT_CONSTANT((guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS);
PRINT_CONSTANT((guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME);
PRINT_CONSTANT((guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_DEVINO_CANONICAL);
PRINT_CONSTANT((guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_ERROR_ON_UNLABELED);
PRINT_CONSTANT((guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES);
PRINT_CONSTANT((guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE);
PRINT_CONSTANT((guint) OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS);
PRINT_CONSTANT((guint) OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL);
PRINT_CONSTANT((guint) OSTREE_REPO_COMMIT_STATE_NORMAL);
PRINT_CONSTANT((guint) OSTREE_REPO_COMMIT_STATE_PARTIAL);
PRINT_CONSTANT((guint) OSTREE_REPO_COMMIT_TRAVERSE_FLAG_COMMIT_ONLY);
PRINT_CONSTANT((guint) OSTREE_REPO_COMMIT_TRAVERSE_FLAG_NONE);
PRINT_CONSTANT((guint) OSTREE_REPO_LIST_OBJECTS_ALL);
PRINT_CONSTANT((guint) OSTREE_REPO_LIST_OBJECTS_LOOSE);
PRINT_CONSTANT((guint) OSTREE_REPO_LIST_OBJECTS_NO_PARENTS);
PRINT_CONSTANT((guint) OSTREE_REPO_LIST_OBJECTS_PACKED);
PRINT_CONSTANT((guint) OSTREE_REPO_LIST_REFS_EXT_ALIASES);
PRINT_CONSTANT((guint) OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS);
PRINT_CONSTANT((guint) OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES);
PRINT_CONSTANT((guint) OSTREE_REPO_LIST_REFS_EXT_NONE);
PRINT_CONSTANT((gint) OSTREE_REPO_LOCK_EXCLUSIVE);
PRINT_CONSTANT((gint) OSTREE_REPO_LOCK_SHARED);
PRINT_CONSTANT(OSTREE_REPO_METADATA_REF);
PRINT_CONSTANT((gint) OSTREE_REPO_MODE_ARCHIVE);
PRINT_CONSTANT((gint) OSTREE_REPO_MODE_ARCHIVE_Z2);
PRINT_CONSTANT((gint) OSTREE_REPO_MODE_BARE);
PRINT_CONSTANT((gint) OSTREE_REPO_MODE_BARE_SPLIT_XATTRS);
PRINT_CONSTANT((gint) OSTREE_REPO_MODE_BARE_USER);
PRINT_CONSTANT((gint) OSTREE_REPO_MODE_BARE_USER_ONLY);
PRINT_CONSTANT((guint) OSTREE_REPO_PRUNE_FLAGS_COMMIT_ONLY);
PRINT_CONSTANT((guint) OSTREE_REPO_PRUNE_FLAGS_NONE);
PRINT_CONSTANT((guint) OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE);
PRINT_CONSTANT((guint) OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY);
PRINT_CONSTANT((guint) OSTREE_REPO_PULL_FLAGS_BAREUSERONLY_FILES);
PRINT_CONSTANT((guint) OSTREE_REPO_PULL_FLAGS_COMMIT_ONLY);
PRINT_CONSTANT((guint) OSTREE_REPO_PULL_FLAGS_MIRROR);
PRINT_CONSTANT((guint) OSTREE_REPO_PULL_FLAGS_NONE);
PRINT_CONSTANT((guint) OSTREE_REPO_PULL_FLAGS_TRUSTED_HTTP);
PRINT_CONSTANT((guint) OSTREE_REPO_PULL_FLAGS_UNTRUSTED);
PRINT_CONSTANT((gint) OSTREE_REPO_REMOTE_CHANGE_ADD);
PRINT_CONSTANT((gint) OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS);
PRINT_CONSTANT((gint) OSTREE_REPO_REMOTE_CHANGE_DELETE);
PRINT_CONSTANT((gint) OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS);
PRINT_CONSTANT((gint) OSTREE_REPO_REMOTE_CHANGE_REPLACE);
PRINT_CONSTANT((guint) OSTREE_REPO_RESOLVE_REV_EXT_LOCAL_ONLY);
PRINT_CONSTANT((guint) OSTREE_REPO_RESOLVE_REV_EXT_NONE);
PRINT_CONSTANT((guint) OSTREE_REPO_VERIFY_FLAGS_NONE);
PRINT_CONSTANT((guint) OSTREE_REPO_VERIFY_FLAGS_NO_GPG);
PRINT_CONSTANT((guint) OSTREE_REPO_VERIFY_FLAGS_NO_SIGNAPI);
PRINT_CONSTANT((guint) OSTREE_SEPOLICY_RESTORECON_FLAGS_ALLOW_NOLABEL);
PRINT_CONSTANT((guint) OSTREE_SEPOLICY_RESTORECON_FLAGS_KEEP_EXISTING);
PRINT_CONSTANT((guint) OSTREE_SEPOLICY_RESTORECON_FLAGS_NONE);
PRINT_CONSTANT(OSTREE_SHA256_DIGEST_LEN);
PRINT_CONSTANT(OSTREE_SHA256_STRING_LEN);
PRINT_CONSTANT(OSTREE_SIGN_NAME_ED25519);
PRINT_CONSTANT((gint) OSTREE_STATIC_DELTA_GENERATE_OPT_LOWLATENCY);
PRINT_CONSTANT((gint) OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR);
PRINT_CONSTANT((gint) OSTREE_STATIC_DELTA_INDEX_FLAGS_NONE);
PRINT_CONSTANT(OSTREE_SUMMARY_GVARIANT_STRING);
PRINT_CONSTANT(OSTREE_SUMMARY_SIG_GVARIANT_STRING);
PRINT_CONSTANT((guint) OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NONE);
PRINT_CONSTANT((guint) OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NOT_DEFAULT);
PRINT_CONSTANT((guint) OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN);
PRINT_CONSTANT((guint) OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN);
PRINT_CONSTANT((guint) OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_PENDING);
PRINT_CONSTANT((guint) OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_ROLLBACK);
PRINT_CONSTANT((guint) OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED);
PRINT_CONSTANT((guint) OSTREE_SYSROOT_UPGRADER_FLAGS_STAGE);
PRINT_CONSTANT((guint) OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_ALLOW_OLDER);
PRINT_CONSTANT((guint) OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_NONE);
PRINT_CONSTANT((guint) OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_SYNTHETIC);
PRINT_CONSTANT(OSTREE_TIMESTAMP);
PRINT_CONSTANT(OSTREE_TREE_GVARIANT_STRING);
return 0;
}

View File

@ -0,0 +1,65 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
#include "manual.h"
#include <stdalign.h>
#include <stdio.h>
int main() {
printf("%s;%zu;%zu\n", "OstreeAsyncProgressClass", sizeof(OstreeAsyncProgressClass), alignof(OstreeAsyncProgressClass));
printf("%s;%zu;%zu\n", "OstreeChecksumFlags", sizeof(OstreeChecksumFlags), alignof(OstreeChecksumFlags));
printf("%s;%zu;%zu\n", "OstreeCollectionRef", sizeof(OstreeCollectionRef), alignof(OstreeCollectionRef));
printf("%s;%zu;%zu\n", "OstreeCollectionRefv", sizeof(OstreeCollectionRefv), alignof(OstreeCollectionRefv));
printf("%s;%zu;%zu\n", "OstreeCommitSizesEntry", sizeof(OstreeCommitSizesEntry), alignof(OstreeCommitSizesEntry));
printf("%s;%zu;%zu\n", "OstreeContentWriterClass", sizeof(OstreeContentWriterClass), alignof(OstreeContentWriterClass));
printf("%s;%zu;%zu\n", "OstreeDeploymentUnlockedState", sizeof(OstreeDeploymentUnlockedState), alignof(OstreeDeploymentUnlockedState));
printf("%s;%zu;%zu\n", "OstreeDiffDirsOptions", sizeof(OstreeDiffDirsOptions), alignof(OstreeDiffDirsOptions));
printf("%s;%zu;%zu\n", "OstreeDiffFlags", sizeof(OstreeDiffFlags), alignof(OstreeDiffFlags));
printf("%s;%zu;%zu\n", "OstreeDiffItem", sizeof(OstreeDiffItem), alignof(OstreeDiffItem));
printf("%s;%zu;%zu\n", "OstreeGpgError", sizeof(OstreeGpgError), alignof(OstreeGpgError));
printf("%s;%zu;%zu\n", "OstreeGpgSignatureAttr", sizeof(OstreeGpgSignatureAttr), alignof(OstreeGpgSignatureAttr));
printf("%s;%zu;%zu\n", "OstreeGpgSignatureFormatFlags", sizeof(OstreeGpgSignatureFormatFlags), alignof(OstreeGpgSignatureFormatFlags));
printf("%s;%zu;%zu\n", "OstreeMutableTreeClass", sizeof(OstreeMutableTreeClass), alignof(OstreeMutableTreeClass));
printf("%s;%zu;%zu\n", "OstreeMutableTreeIter", sizeof(OstreeMutableTreeIter), alignof(OstreeMutableTreeIter));
printf("%s;%zu;%zu\n", "OstreeObjectType", sizeof(OstreeObjectType), alignof(OstreeObjectType));
printf("%s;%zu;%zu\n", "OstreeRepoCheckoutAtOptions", sizeof(OstreeRepoCheckoutAtOptions), alignof(OstreeRepoCheckoutAtOptions));
printf("%s;%zu;%zu\n", "OstreeRepoCheckoutFilterResult", sizeof(OstreeRepoCheckoutFilterResult), alignof(OstreeRepoCheckoutFilterResult));
printf("%s;%zu;%zu\n", "OstreeRepoCheckoutMode", sizeof(OstreeRepoCheckoutMode), alignof(OstreeRepoCheckoutMode));
printf("%s;%zu;%zu\n", "OstreeRepoCheckoutOverwriteMode", sizeof(OstreeRepoCheckoutOverwriteMode), alignof(OstreeRepoCheckoutOverwriteMode));
printf("%s;%zu;%zu\n", "OstreeRepoCommitFilterResult", sizeof(OstreeRepoCommitFilterResult), alignof(OstreeRepoCommitFilterResult));
printf("%s;%zu;%zu\n", "OstreeRepoCommitIterResult", sizeof(OstreeRepoCommitIterResult), alignof(OstreeRepoCommitIterResult));
printf("%s;%zu;%zu\n", "OstreeRepoCommitModifierFlags", sizeof(OstreeRepoCommitModifierFlags), alignof(OstreeRepoCommitModifierFlags));
printf("%s;%zu;%zu\n", "OstreeRepoCommitState", sizeof(OstreeRepoCommitState), alignof(OstreeRepoCommitState));
printf("%s;%zu;%zu\n", "OstreeRepoCommitTraverseFlags", sizeof(OstreeRepoCommitTraverseFlags), alignof(OstreeRepoCommitTraverseFlags));
printf("%s;%zu;%zu\n", "OstreeRepoCommitTraverseIter", sizeof(OstreeRepoCommitTraverseIter), alignof(OstreeRepoCommitTraverseIter));
printf("%s;%zu;%zu\n", "OstreeRepoFileClass", sizeof(OstreeRepoFileClass), alignof(OstreeRepoFileClass));
printf("%s;%zu;%zu\n", "OstreeRepoFinderAvahiClass", sizeof(OstreeRepoFinderAvahiClass), alignof(OstreeRepoFinderAvahiClass));
printf("%s;%zu;%zu\n", "OstreeRepoFinderConfigClass", sizeof(OstreeRepoFinderConfigClass), alignof(OstreeRepoFinderConfigClass));
printf("%s;%zu;%zu\n", "OstreeRepoFinderInterface", sizeof(OstreeRepoFinderInterface), alignof(OstreeRepoFinderInterface));
printf("%s;%zu;%zu\n", "OstreeRepoFinderMountClass", sizeof(OstreeRepoFinderMountClass), alignof(OstreeRepoFinderMountClass));
printf("%s;%zu;%zu\n", "OstreeRepoFinderOverrideClass", sizeof(OstreeRepoFinderOverrideClass), alignof(OstreeRepoFinderOverrideClass));
printf("%s;%zu;%zu\n", "OstreeRepoFinderResult", sizeof(OstreeRepoFinderResult), alignof(OstreeRepoFinderResult));
printf("%s;%zu;%zu\n", "OstreeRepoFinderResultv", sizeof(OstreeRepoFinderResultv), alignof(OstreeRepoFinderResultv));
printf("%s;%zu;%zu\n", "OstreeRepoListObjectsFlags", sizeof(OstreeRepoListObjectsFlags), alignof(OstreeRepoListObjectsFlags));
printf("%s;%zu;%zu\n", "OstreeRepoListRefsExtFlags", sizeof(OstreeRepoListRefsExtFlags), alignof(OstreeRepoListRefsExtFlags));
printf("%s;%zu;%zu\n", "OstreeRepoLockType", sizeof(OstreeRepoLockType), alignof(OstreeRepoLockType));
printf("%s;%zu;%zu\n", "OstreeRepoMode", sizeof(OstreeRepoMode), alignof(OstreeRepoMode));
printf("%s;%zu;%zu\n", "OstreeRepoPruneFlags", sizeof(OstreeRepoPruneFlags), alignof(OstreeRepoPruneFlags));
printf("%s;%zu;%zu\n", "OstreeRepoPruneOptions", sizeof(OstreeRepoPruneOptions), alignof(OstreeRepoPruneOptions));
printf("%s;%zu;%zu\n", "OstreeRepoPullFlags", sizeof(OstreeRepoPullFlags), alignof(OstreeRepoPullFlags));
printf("%s;%zu;%zu\n", "OstreeRepoRemoteChange", sizeof(OstreeRepoRemoteChange), alignof(OstreeRepoRemoteChange));
printf("%s;%zu;%zu\n", "OstreeRepoResolveRevExtFlags", sizeof(OstreeRepoResolveRevExtFlags), alignof(OstreeRepoResolveRevExtFlags));
printf("%s;%zu;%zu\n", "OstreeRepoTransactionStats", sizeof(OstreeRepoTransactionStats), alignof(OstreeRepoTransactionStats));
printf("%s;%zu;%zu\n", "OstreeRepoVerifyFlags", sizeof(OstreeRepoVerifyFlags), alignof(OstreeRepoVerifyFlags));
printf("%s;%zu;%zu\n", "OstreeSePolicyRestoreconFlags", sizeof(OstreeSePolicyRestoreconFlags), alignof(OstreeSePolicyRestoreconFlags));
printf("%s;%zu;%zu\n", "OstreeSignInterface", sizeof(OstreeSignInterface), alignof(OstreeSignInterface));
printf("%s;%zu;%zu\n", "OstreeStaticDeltaGenerateOpt", sizeof(OstreeStaticDeltaGenerateOpt), alignof(OstreeStaticDeltaGenerateOpt));
printf("%s;%zu;%zu\n", "OstreeStaticDeltaIndexFlags", sizeof(OstreeStaticDeltaIndexFlags), alignof(OstreeStaticDeltaIndexFlags));
printf("%s;%zu;%zu\n", "OstreeSysrootDeployTreeOpts", sizeof(OstreeSysrootDeployTreeOpts), alignof(OstreeSysrootDeployTreeOpts));
printf("%s;%zu;%zu\n", "OstreeSysrootSimpleWriteDeploymentFlags", sizeof(OstreeSysrootSimpleWriteDeploymentFlags), alignof(OstreeSysrootSimpleWriteDeploymentFlags));
printf("%s;%zu;%zu\n", "OstreeSysrootUpgraderFlags", sizeof(OstreeSysrootUpgraderFlags), alignof(OstreeSysrootUpgraderFlags));
printf("%s;%zu;%zu\n", "OstreeSysrootUpgraderPullFlags", sizeof(OstreeSysrootUpgraderPullFlags), alignof(OstreeSysrootUpgraderPullFlags));
printf("%s;%zu;%zu\n", "OstreeSysrootWriteDeploymentsOpts", sizeof(OstreeSysrootWriteDeploymentsOpts), alignof(OstreeSysrootWriteDeploymentsOpts));
return 0;
}

View File

@ -0,0 +1,9 @@
// Feel free to edit this file, it won't be regenerated by gir generator unless removed.
#include <ostree.h>
// hack to build and test on versions of libostree < 2019.2
#if !OSTREE_CHECK_VERSION(2019, 2)
# define OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS 4
# define OSTREE_REPO_REMOTE_CHANGE_REPLACE 4
# define OSTREE_REPO_RESOLVE_REV_EXT_LOCAL_ONLY 1
#endif

View File

@ -0,0 +1,13 @@
use crate::util::*;
use std::error::Error;
#[test]
fn variant_types() -> Result<(), Box<dyn Error>> {
let tr = TestRepo::new();
let commit_checksum = tr.test_commit("test");
let repo = &tr.repo;
let commit_v = repo.load_variant(ostree::ObjectType::Commit, commit_checksum.as_str())?;
let commit = commit_v.get::<ostree::CommitVariantType>().unwrap();
assert_eq!(commit.3, "Test Commit");
Ok(())
}

Binary file not shown.

View File

@ -0,0 +1,71 @@
use crate::util::TestRepo;
use gio::NONE_CANCELLABLE;
use ostree::{checksum_file_from_input, ObjectType};
#[test]
fn list_repo_objects() {
let repo = TestRepo::new();
let commit_checksum = repo.test_commit("test");
let mut dirtree_cnt = 0;
let mut dirmeta_cnt = 0;
let mut file_cnt = 0;
let mut commit_cnt = 0;
let objects = repo
.repo
.list_objects(ffi::OSTREE_REPO_LIST_OBJECTS_ALL, NONE_CANCELLABLE)
.expect("List Objects");
for (object, _items) in objects {
match object.object_type() {
ObjectType::DirTree => {
dirtree_cnt += 1;
}
ObjectType::DirMeta => {
dirmeta_cnt += 1;
}
ObjectType::File => {
file_cnt += 1;
}
ObjectType::Commit => {
assert_eq!(commit_checksum.to_string(), object.checksum());
commit_cnt += 1;
}
x => {
panic!("unexpected object type {}", x);
}
}
}
assert_eq!(dirtree_cnt, 2);
assert_eq!(dirmeta_cnt, 1);
assert_eq!(file_cnt, 1);
assert_eq!(commit_cnt, 1);
}
#[test]
fn should_checksum_file_from_input() {
let repo = TestRepo::new();
let commit_checksum = repo.test_commit("test");
let objects = repo
.repo
.traverse_commit(&commit_checksum, -1, NONE_CANCELLABLE)
.expect("traverse commit");
for obj in objects {
if obj.object_type() != ObjectType::File {
continue;
}
let (stream, file_info, xattrs) = repo
.repo
.load_file(obj.checksum(), NONE_CANCELLABLE)
.expect("load file");
let result = checksum_file_from_input(
file_info.as_ref().unwrap(),
xattrs.as_ref(),
stream.as_ref(),
ObjectType::File,
NONE_CANCELLABLE,
)
.expect("checksum file from input");
assert_eq!(result.to_string(), obj.checksum());
}
}

View File

@ -0,0 +1,108 @@
use crate::util::*;
use gio::NONE_CANCELLABLE;
use ostree::*;
use std::os::unix::io::AsRawFd;
#[test]
fn should_checkout_at_with_none_options() {
let test_repo = TestRepo::new();
let checksum = test_repo.test_commit("test");
let checkout_dir = tempfile::tempdir().expect("checkout dir");
let dirfd = openat::Dir::open(checkout_dir.path()).expect("openat");
test_repo
.repo
.checkout_at(
None,
dirfd.as_raw_fd(),
"test-checkout",
&checksum,
NONE_CANCELLABLE,
)
.expect("checkout at");
assert_test_file(checkout_dir.path());
}
#[test]
fn should_checkout_at_with_default_options() {
let test_repo = TestRepo::new();
let checksum = test_repo.test_commit("test");
let checkout_dir = tempfile::tempdir().expect("checkout dir");
let dirfd = openat::Dir::open(checkout_dir.path()).expect("openat");
test_repo
.repo
.checkout_at(
Some(&RepoCheckoutAtOptions::default()),
dirfd.as_raw_fd(),
"test-checkout",
&checksum,
NONE_CANCELLABLE,
)
.expect("checkout at");
assert_test_file(checkout_dir.path());
}
#[test]
fn should_checkout_at_with_options() {
let test_repo = TestRepo::new();
let checksum = test_repo.test_commit("test");
let checkout_dir = tempfile::tempdir().expect("checkout dir");
let dirfd = openat::Dir::open(checkout_dir.path()).expect("openat");
test_repo
.repo
.checkout_at(
Some(&RepoCheckoutAtOptions {
mode: RepoCheckoutMode::User,
overwrite_mode: RepoCheckoutOverwriteMode::AddFiles,
enable_fsync: true,
devino_to_csum_cache: Some(RepoDevInoCache::new()),
..Default::default()
}),
dirfd.as_raw_fd(),
"test-checkout",
&checksum,
NONE_CANCELLABLE,
)
.expect("checkout at");
assert_test_file(checkout_dir.path());
}
#[test]
#[cfg(feature = "v2018_2")]
fn should_checkout_at_with_filter() {
use std::path::Path;
let test_repo = TestRepo::new();
let checksum = test_repo.test_commit("test");
let checkout_dir = tempfile::tempdir().expect("checkout dir");
let dirfd = openat::Dir::open(checkout_dir.path()).expect("openat");
test_repo
.repo
.checkout_at(
Some(&RepoCheckoutAtOptions {
filter: RepoCheckoutFilter::new(|_repo, path, _stat| {
if path == Path::new("/testdir/testfile") {
RepoCheckoutFilterResult::Skip
} else {
RepoCheckoutFilterResult::Allow
}
}),
..Default::default()
}),
dirfd.as_raw_fd(),
"test-checkout",
&checksum,
NONE_CANCELLABLE,
)
.expect("checkout at");
let testdir = checkout_dir.path().join("test-checkout").join("testdir");
assert!(std::fs::read_dir(&testdir).is_ok());
assert!(std::fs::File::open(&testdir.join("testfile")).is_err());
}

View File

@ -0,0 +1,186 @@
use crate::util::*;
use ostree::gio::NONE_CANCELLABLE;
use ostree::prelude::*;
use ostree::{ObjectName, ObjectType};
#[cfg(feature = "v2016_8")]
mod checkout_at;
#[test]
fn should_commit_content_to_repo_and_list_refs_again() {
let test_repo = TestRepo::new();
assert!(test_repo.repo.require_rev("nosuchrev").is_err());
let mtree = create_mtree(&test_repo.repo);
let checksum = commit(&test_repo.repo, &mtree, "test");
assert_eq!(test_repo.repo.require_rev("test").unwrap(), checksum);
let repo = ostree::Repo::new_for_path(test_repo.dir.path());
repo.open(NONE_CANCELLABLE).expect("OSTree test_repo");
let refs = repo
.list_refs(None, NONE_CANCELLABLE)
.expect("failed to list refs");
assert_eq!(1, refs.len());
assert_eq!(checksum, refs["test"]);
}
#[test]
#[cfg(feature = "cap-std-apis")]
fn cap_std_commit() {
let test_repo = CapTestRepo::new();
assert!(test_repo.dir.exists("config"));
// Also test re-acquiring a new dfd
assert!(test_repo.repo.dfd_as_dir().unwrap().exists("config"));
assert!(test_repo.repo.require_rev("nosuchrev").is_err());
let mtree = create_mtree(&test_repo.repo);
let checksum = commit(&test_repo.repo, &mtree, "test");
assert_eq!(test_repo.repo.require_rev("test").unwrap(), checksum);
let repo2 = ostree::Repo::open_at_dir(&test_repo.dir, ".").unwrap();
let refs = repo2
.list_refs(None, NONE_CANCELLABLE)
.expect("failed to list refs");
assert_eq!(1, refs.len());
assert_eq!(checksum, refs["test"]);
}
#[test]
fn repo_traverse_and_read() {
let test_repo = TestRepo::new();
let checksum = test_repo.test_commit("test");
let objects = test_repo
.repo
.traverse_commit(&checksum, -1, NONE_CANCELLABLE)
.expect("traverse commit");
assert_eq!(
maplit::hashset!(
ObjectName::new(
"89f84ca9854a80e85b583e46a115ba4985254437027bad34f0b113219323d3f8",
ObjectType::File
),
ObjectName::new(
"5280a884f930cae329e2e39d52f2c8e910c2ef4733216b67679db32a2b56c4db",
ObjectType::DirTree
),
ObjectName::new(
"c81acde323d73f8639fc84f1ded17bbafc415e645f845e9f3b16a4906857c2d4",
ObjectType::DirTree
),
ObjectName::new(
"ad49a0f4e3bc165361b6d17e8a865d479b373ee67d89ac6f0ce871f27da1be6d",
ObjectType::DirMeta
),
ObjectName::new(checksum, ObjectType::Commit)
),
objects
);
let dirmeta = test_repo
.repo
.read_dirmeta("ad49a0f4e3bc165361b6d17e8a865d479b373ee67d89ac6f0ce871f27da1be6d")
.unwrap();
// Right now, the uid/gid are actually that of the test runner
assert_eq!(dirmeta.mode, 0o40750);
let (finfo, _xattrs) = test_repo
.repo
.query_file(
"89f84ca9854a80e85b583e46a115ba4985254437027bad34f0b113219323d3f8",
NONE_CANCELLABLE,
)
.unwrap();
assert_eq!(finfo.size(), 5);
}
#[test]
fn should_checkout_tree() {
let test_repo = TestRepo::new();
let _ = test_repo.test_commit("test");
let checkout_dir = tempfile::tempdir().expect("checkout dir");
let file = test_repo
.repo
.read_commit("test", NONE_CANCELLABLE)
.expect("read commit")
.0
.downcast::<ostree::RepoFile>()
.expect("RepoFile");
let info = file
.query_info("*", gio::FileQueryInfoFlags::NONE, NONE_CANCELLABLE)
.expect("file info");
test_repo
.repo
.checkout_tree(
ostree::RepoCheckoutMode::User,
ostree::RepoCheckoutOverwriteMode::None,
&gio::File::for_path(checkout_dir.path().join("test-checkout")),
&file,
&info,
NONE_CANCELLABLE,
)
.expect("checkout tree");
assert_test_file(checkout_dir.path());
}
#[test]
fn should_write_content_to_repo() {
let src = TestRepo::new();
let mtree = create_mtree(&src.repo);
let checksum = commit(&src.repo, &mtree, "test");
let dest = TestRepo::new();
let objects = src
.repo
.traverse_commit(&checksum, -1, NONE_CANCELLABLE)
.expect("traverse");
for obj in objects {
match obj.object_type() {
ObjectType::File => copy_file(&src, &dest, &obj),
_ => copy_metadata(&src, &dest, &obj),
}
}
}
#[test]
#[cfg(feature = "v2016_4")]
fn repo_file() {
use std::os::unix::fs::MetadataExt;
let test_repo = TestRepo::new();
let m1 = test_repo.repo.dfd_as_file().unwrap().metadata().unwrap();
let m2 = test_repo.repo.dfd_as_file().unwrap().metadata().unwrap();
assert_eq!(m1.dev(), m2.dev());
assert_eq!(m1.ino(), m2.ino());
}
fn copy_file(src: &TestRepo, dest: &TestRepo, obj: &ObjectName) {
let (stream, len) = src
.repo
.load_object_stream(obj.object_type(), obj.checksum(), NONE_CANCELLABLE)
.expect("load object stream");
let out_csum = dest
.repo
.write_content(None, &stream, len, NONE_CANCELLABLE)
.expect("write content");
assert_eq!(out_csum.to_string(), obj.checksum());
}
fn copy_metadata(src: &TestRepo, dest: &TestRepo, obj: &ObjectName) {
let data = src
.repo
.load_variant(obj.object_type(), obj.checksum())
.expect("load variant");
let out_csum = dest
.repo
.write_metadata(obj.object_type(), None, &data, NONE_CANCELLABLE)
.expect("write metadata");
assert_eq!(out_csum.to_string(), obj.checksum());
}

View File

@ -0,0 +1,21 @@
use ostree::prelude::*;
use ostree::{gio, glib};
#[test]
fn sign_api_should_work() {
let dummy_sign = ostree::Sign::by_name("dummy").unwrap();
assert_eq!(dummy_sign.name().unwrap(), "dummy");
let result = ostree::prelude::SignExt::data(
&dummy_sign,
&glib::Bytes::from_static(b"1234"),
gio::NONE_CANCELLABLE,
);
assert!(result.is_err());
let result = dummy_sign.data_verify(&glib::Bytes::from_static(b"1234"), &"1234".to_variant());
assert!(result.is_err());
let result = ostree::Sign::by_name("NOPE");
assert!(result.is_err());
}

View File

@ -0,0 +1,6 @@
mod core;
mod functions;
mod repo;
#[cfg(feature = "v2020_2")]
mod sign;
mod util;

View File

@ -0,0 +1,98 @@
use gio::NONE_CANCELLABLE;
use glib::prelude::*;
use glib::GString;
use std::path::Path;
#[derive(Debug)]
pub struct TestRepo {
pub dir: tempfile::TempDir,
pub repo: ostree::Repo,
}
impl TestRepo {
pub fn new() -> TestRepo {
TestRepo::new_with_mode(ostree::RepoMode::Archive)
}
pub fn new_with_mode(repo_mode: ostree::RepoMode) -> TestRepo {
let dir = tempfile::tempdir().expect("temp repo dir");
let repo = ostree::Repo::new_for_path(dir.path());
repo.create(repo_mode, NONE_CANCELLABLE)
.expect("OSTree repo");
TestRepo { dir, repo }
}
pub fn test_commit(&self, ref_: &str) -> GString {
let mtree = create_mtree(&self.repo);
commit(&self.repo, &mtree, ref_)
}
}
#[derive(Debug)]
#[cfg(feature = "cap-std-apis")]
pub struct CapTestRepo {
pub dir: cap_tempfile::TempDir,
pub repo: ostree::Repo,
}
#[cfg(feature = "cap-std-apis")]
impl CapTestRepo {
pub fn new() -> Self {
Self::new_with_mode(ostree::RepoMode::Archive)
}
pub fn new_with_mode(repo_mode: ostree::RepoMode) -> Self {
let dir = cap_tempfile::tempdir(cap_std::ambient_authority()).unwrap();
let repo = ostree::Repo::create_at_dir(&dir, ".", repo_mode, None).expect("repo create");
Self { dir, repo }
}
}
pub fn create_mtree(repo: &ostree::Repo) -> ostree::MutableTree {
let mtree = ostree::MutableTree::new();
assert_eq!(mtree.copy_files().len(), 0);
assert_eq!(mtree.copy_subdirs().len(), 0);
let file = gio::File::for_path(
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("data")
.join("test.tar"),
);
repo.write_archive_to_mtree(&file, &mtree, None, true, NONE_CANCELLABLE)
.expect("test mtree");
mtree
}
pub fn commit(repo: &ostree::Repo, mtree: &ostree::MutableTree, ref_: &str) -> GString {
let txn = repo
.auto_transaction(NONE_CANCELLABLE)
.expect("prepare transaction");
let repo_file = txn
.repo()
.write_mtree(mtree, NONE_CANCELLABLE)
.expect("write mtree")
.downcast::<ostree::RepoFile>()
.unwrap();
let checksum = repo
.write_commit(
None,
"Test Commit".into(),
None,
None,
&repo_file,
NONE_CANCELLABLE,
)
.expect("write commit");
repo.transaction_set_ref(None, ref_, checksum.as_str().into());
txn.commit(NONE_CANCELLABLE).expect("commit transaction");
checksum
}
pub fn assert_test_file(checkout: &Path) {
let testfile_path = checkout
.join("test-checkout")
.join("testdir")
.join("testfile");
let testfile_contents = std::fs::read_to_string(testfile_path).expect("test file");
assert_eq!("test\n", testfile_contents);
}

2
tests/inst/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
Cargo.lock
target/

View File

@ -4,6 +4,8 @@ version = "0.1.0"
authors = ["Colin Walters <walters@verbum.org>"]
edition = "2018"
[workspace]
[[bin]]
name = "ostree-test"
path = "src/insttestmain.rs"

View File

@ -12,6 +12,6 @@ all:
install:
install -D -m 0644 -t $(KOLA_TESTDIR) $(LIBSCRIPTS)
for x in $(TESTDIRS); do rsync -rlv ./$${x} $(KOLA_TESTDIR)/; done
install -D -m 0755 -t $(KOLA_TESTDIR)/nondestructive-rs ../../target/release/ostree-test
install -D -m 0755 -t $(KOLA_TESTDIR)/nondestructive-rs ../inst/target/release/ostree-test
install -D -m 0644 destructive-stamp.ign $(KOLA_TESTDIR)/destructive-rs/config.ign
./install-wrappers.sh destructive-list.txt $(KOLA_TESTDIR)/destructive-rs