summaryrefslogtreecommitdiff
path: root/rust-bindings/src/auto/repo_file.rs
blob: d480e76326f4bdce0d37a73725d0757b06965d7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// 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 is_ok = ffi::ostree_repo_file_ensure_resolved(self.to_glib_none().0, &mut error);
            assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            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) -> 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) -> 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")]
#[must_use]
    pub fn root(&self) -> 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(&self, cancellable: Option<&impl IsA<gio::Cancellable>>) -> Result<glib::Variant, glib::Error> {
        unsafe {
            let mut out_xattrs = ptr::null_mut();
            let mut error = ptr::null_mut();
            let is_ok = 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);
            assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            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);
            (ret, from_glib(is_dir.assume_init()), 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(&self, n: i32, attributes: &str, flags: gio::FileQueryInfoFlags, cancellable: Option<&impl IsA<gio::Cancellable>>) -> Result<gio::FileInfo, glib::Error> {
        unsafe {
            let mut out_info = ptr::null_mut();
            let mut error = ptr::null_mut();
            let is_ok = 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);
            assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            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")
    }
}