Deny unused results, warn on missing docs (except auto/)

And add basic docs for our manually implemented functions.
This commit is contained in:
Colin Walters 2021-08-02 15:51:49 -04:00
parent f3df1175f8
commit 48e0d334b8
5 changed files with 21 additions and 1 deletions

View File

@ -19,10 +19,13 @@ fn base64_config() -> &'static radix64::CustomConfig {
}) })
} }
/// Error returned from parsing a checksum.
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum ChecksumError { pub enum ChecksumError {
/// Invalid hex checksum string.
#[error("invalid hex checksum string")] #[error("invalid hex checksum string")]
InvalidHexString, InvalidHexString,
/// Invalid base64 checksum string
#[error("invalid base64 checksum string")] #[error("invalid base64 checksum string")]
InvalidBase64String, InvalidBase64String,
} }

View File

@ -5,6 +5,7 @@ use glib::{prelude::*, translate::*};
use glib_sys::GFALSE; use glib_sys::GFALSE;
use std::{future::Future, mem::MaybeUninit, pin::Pin, ptr}; 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>>( pub fn checksum_file<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(
f: &P, f: &P,
objtype: ObjectType, objtype: ObjectType,
@ -24,6 +25,7 @@ pub fn checksum_file<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(
} }
} }
/// Asynchronously compute the SHA-256 checksum of a file.
pub fn checksum_file_async< pub fn checksum_file_async<
P: IsA<gio::File>, P: IsA<gio::File>,
Q: IsA<gio::Cancellable>, Q: IsA<gio::Cancellable>,
@ -69,6 +71,7 @@ pub fn checksum_file_async<
} }
} }
/// Asynchronously compute the SHA-256 checksum of a file.
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
pub fn checksum_file_async_future<P: IsA<gio::File> + Clone + 'static>( pub fn checksum_file_async_future<P: IsA<gio::File> + Clone + 'static>(
f: &P, f: &P,
@ -83,6 +86,7 @@ pub fn checksum_file_async_future<P: IsA<gio::File> + Clone + 'static>(
})) }))
} }
/// Compute the OSTree checksum of a content object.
pub fn checksum_file_from_input<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>( pub fn checksum_file_from_input<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(
file_info: &gio::FileInfo, file_info: &gio::FileInfo,
xattrs: Option<&glib::Variant>, xattrs: Option<&glib::Variant>,

View File

@ -5,6 +5,9 @@
//! along with a layer for deploying them and managing the bootloader configuration. //! along with a layer for deploying them and managing the bootloader configuration.
#![cfg_attr(feature = "dox", feature(doc_cfg))] #![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 // 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 // "Dependencies are re-exported". Users will need e.g. `gio::File`, so this avoids
@ -16,6 +19,7 @@ pub use glib;
#[rustfmt::skip] #[rustfmt::skip]
#[allow(clippy::all)] #[allow(clippy::all)]
#[allow(unused_imports)] #[allow(unused_imports)]
#[allow(missing_docs)]
mod auto; mod auto;
pub use crate::auto::functions::*; pub use crate::auto::functions::*;
pub use crate::auto::*; pub use crate::auto::*;
@ -62,7 +66,7 @@ pub use crate::sysroot_deploy_tree_opts::SysrootDeployTreeOpts;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
// prelude /// Prelude, intended for glob imports.
pub mod prelude { pub mod prelude {
pub use crate::auto::traits::*; pub use crate::auto::traits::*;
// See "Re-export dependencies above". // See "Re-export dependencies above".

View File

@ -41,6 +41,7 @@ impl Repo {
Repo::new(&gio::File::for_path(path.as_ref())) Repo::new(&gio::File::for_path(path.as_ref()))
} }
/// Find all objects reachable from a commit.
pub fn traverse_commit<P: IsA<gio::Cancellable>>( pub fn traverse_commit<P: IsA<gio::Cancellable>>(
&self, &self,
commit_checksum: &str, commit_checksum: &str,
@ -66,6 +67,7 @@ impl Repo {
} }
} }
/// List all branch names (refs).
pub fn list_refs<P: IsA<gio::Cancellable>>( pub fn list_refs<P: IsA<gio::Cancellable>>(
&self, &self,
refspec_prefix: Option<&str>, refspec_prefix: Option<&str>,
@ -117,6 +119,7 @@ impl Repo {
} }
} }
/// Write a content object from provided input.
pub fn write_content<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>( pub fn write_content<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(
&self, &self,
expected_checksum: Option<&str>, expected_checksum: Option<&str>,
@ -144,6 +147,7 @@ impl Repo {
} }
} }
/// Write a metadata object.
pub fn write_metadata<P: IsA<gio::Cancellable>>( pub fn write_metadata<P: IsA<gio::Cancellable>>(
&self, &self,
objtype: ObjectType, objtype: ObjectType,
@ -171,6 +175,7 @@ impl Repo {
} }
} }
/// Asynchronously write a content object.
pub fn write_content_async< pub fn write_content_async<
P: IsA<gio::InputStream>, P: IsA<gio::InputStream>,
Q: IsA<gio::Cancellable>, Q: IsA<gio::Cancellable>,
@ -222,6 +227,7 @@ impl Repo {
} }
} }
/// Asynchronously write a content object.
pub fn write_content_async_future<P: IsA<gio::InputStream> + Clone + 'static>( pub fn write_content_async_future<P: IsA<gio::InputStream> + Clone + 'static>(
&self, &self,
expected_checksum: Option<&str>, expected_checksum: Option<&str>,
@ -245,6 +251,7 @@ impl Repo {
})) }))
} }
/// Asynchronously write a metadata object.
pub fn write_metadata_async< pub fn write_metadata_async<
P: IsA<gio::Cancellable>, P: IsA<gio::Cancellable>,
Q: FnOnce(Result<Checksum, Error>) + Send + 'static, Q: FnOnce(Result<Checksum, Error>) + Send + 'static,
@ -295,6 +302,7 @@ impl Repo {
} }
} }
/// Asynchronously write a metadata object.
pub fn write_metadata_async_future( pub fn write_metadata_async_future(
&self, &self,
objtype: ObjectType, objtype: ObjectType,

View File

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