Skip to content

Commit

Permalink
Correct some docu
Browse files Browse the repository at this point in the history
  • Loading branch information
aawsome committed Aug 14, 2023
1 parent d7bfe84 commit b570924
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 29 deletions.
4 changes: 2 additions & 2 deletions crates/rustic_core/src/archiver/parent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ pub struct Parent {
/// * `T` - The type of the matched parent.
#[derive(Clone, Debug)]
pub(crate) enum ParentResult<T> {
/// The parent was found.
/// The parent was found and matches.
Matched(T),
/// The parent was not found.
NotFound,
/// The parent was found but not matched.
/// The parent was found but doesn't match.
NotMatched,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rustic_core/src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ fn check_packs(
let mut index_collector = IndexCollector::new(if read_data {
IndexType::Full
} else {
IndexType::FullTrees
IndexType::DataIds
});

let mut process_pack = |p: IndexPack, check_time: bool| {
Expand Down
32 changes: 15 additions & 17 deletions crates/rustic_core/src/crypto/aespoly1305.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ use crate::{crypto::CryptoKey, error::CryptoErrorKind, error::RusticResult};
pub(crate) type Nonce = aead::Nonce<Aes256CtrPoly1305Aes>;
pub(crate) type AeadKey = aead::Key<Aes256CtrPoly1305Aes>;

/// The `Key` is used to encrypt and decrypt data.
/// The `Key` is used to encrypt/MAC and check/decrypt data.
///
/// It is a 64 byte key that is used to derive the encryption, kdf, and random keys.
/// It is a 64 byte key that is used to derive the AES256 encryption key and the numbers `k` and `r` used in the Poly1305AES MAC.

Check failure on line 14 in crates/rustic_core/src/crypto/aespoly1305.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

item in documentation is missing backticks

error: item in documentation is missing backticks --> crates/rustic_core/src/crypto/aespoly1305.rs:14:114 | 14 | /// It is a 64 byte key that is used to derive the AES256 encryption key and the numbers `k` and `r` used in the Poly1305AES MAC. | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown = note: `-D clippy::doc-markdown` implied by `-D warnings` help: try | 14 | /// It is a 64 byte key that is used to derive the AES256 encryption key and the numbers `k` and `r` used in the `Poly1305AES` MAC. | ~~~~~~~~~~~~~
///
/// The first 32 bytes are used for encryption.
/// The first 32 bytes are used for the AES256 encryption.
///
/// The next 16 bytes are used for the kdf.
/// The next 16 bytes are used for the number `k` of Poly1305AES.

Check failure on line 18 in crates/rustic_core/src/crypto/aespoly1305.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

item in documentation is missing backticks

error: item in documentation is missing backticks --> crates/rustic_core/src/crypto/aespoly1305.rs:18:54 | 18 | /// The next 16 bytes are used for the number `k` of Poly1305AES. | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 18 | /// The next 16 bytes are used for the number `k` of `Poly1305AES`. | ~~~~~~~~~~~~~
///
/// The last 16 bytes are used for random data.
///
/// The key is generated randomly.
/// The last 16 bytes are used for the number `r` of Poly1305AES.

Check failure on line 20 in crates/rustic_core/src/crypto/aespoly1305.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

item in documentation is missing backticks

error: item in documentation is missing backticks --> crates/rustic_core/src/crypto/aespoly1305.rs:20:54 | 20 | /// The last 16 bytes are used for the number `r` of Poly1305AES. | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 20 | /// The last 16 bytes are used for the number `r` of `Poly1305AES`. | ~~~~~~~~~~~~~
///
/// # Examples
///
Expand All @@ -40,7 +38,7 @@ pub(crate) type AeadKey = aead::Key<Aes256CtrPoly1305Aes>;
pub struct Key(AeadKey);

impl Key {
/// Create a new [`Key`] with a random key.
/// Create a new random [`Key`] using a suitable entropy source.
#[must_use]
pub fn new() -> Self {
let mut key = AeadKey::default();
Expand All @@ -58,13 +56,13 @@ impl Key {
Self(*AeadKey::from_slice(key))
}

/// Create a new [`Key`] from the encryption, kdf, and random keys. The keys are concatenated together.
/// Create a new [`Key`] from the AES key and numbers `k` and `r` for Poly1305AES.

Check failure on line 59 in crates/rustic_core/src/crypto/aespoly1305.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

item in documentation is missing backticks

error: item in documentation is missing backticks --> crates/rustic_core/src/crypto/aespoly1305.rs:59:75 | 59 | /// Create a new [`Key`] from the AES key and numbers `k` and `r` for Poly1305AES. | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 59 | /// Create a new [`Key`] from the AES key and numbers `k` and `r` for `Poly1305AES`. | ~~~~~~~~~~~~~
///
/// # Arguments
///
/// * `encrypt` - The encryption key.
/// * `k` - The kdf key.
/// * `r` - The random key.
/// * `encrypt` - The AES key.
/// * `k` - The number k for Poly1305AES.

Check failure on line 64 in crates/rustic_core/src/crypto/aespoly1305.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

item in documentation is missing backticks

error: item in documentation is missing backticks --> crates/rustic_core/src/crypto/aespoly1305.rs:64:34 | 64 | /// * `k` - The number k for Poly1305AES. | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 64 | /// * `k` - The number k for `Poly1305AES`. | ~~~~~~~~~~~~~
/// * `r` - The number r for Poly1305AES.

Check failure on line 65 in crates/rustic_core/src/crypto/aespoly1305.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

item in documentation is missing backticks

error: item in documentation is missing backticks --> crates/rustic_core/src/crypto/aespoly1305.rs:65:34 | 65 | /// * `r` - The number r for Poly1305AES. | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 65 | /// * `r` - The number r for `Poly1305AES`. | ~~~~~~~~~~~~~
#[must_use]
pub fn from_keys(encrypt: &[u8], k: &[u8], r: &[u8]) -> Self {
let mut key = AeadKey::default();
Expand All @@ -75,7 +73,7 @@ impl Key {
Self(key)
}

/// Returns the encryption, kdf, and random keys.
/// Returns the AES key and numbers `k`and `r` for Poly1305AES.

Check failure on line 76 in crates/rustic_core/src/crypto/aespoly1305.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

item in documentation is missing backticks

error: item in documentation is missing backticks --> crates/rustic_core/src/crypto/aespoly1305.rs:76:56 | 76 | /// Returns the AES key and numbers `k`and `r` for Poly1305AES. | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown help: try | 76 | /// Returns the AES key and numbers `k`and `r` for `Poly1305AES`. | ~~~~~~~~~~~~~
#[must_use]
pub fn to_keys(self) -> (Vec<u8>, Vec<u8>, Vec<u8>) {
let mut encrypt = vec![0; 32];
Expand All @@ -90,15 +88,15 @@ impl Key {
}

impl CryptoKey for Key {
/// Returns the decrypted data from the given encrypted data.
/// Returns the decrypted data from the given encrypted/MACed data.
///
/// # Arguments
///
/// * `data` - The encrypted data.
/// * `data` - The encrypted/MACed data.
///
/// # Errors
///
/// If the data could not be decrypted.
/// If the MAC couldn't be checked.
fn decrypt_data(&self, data: &[u8]) -> RusticResult<Vec<u8>> {
if data.len() < 16 {
return Err(CryptoErrorKind::CryptoKeyTooShort)?;
Expand All @@ -110,7 +108,7 @@ impl CryptoKey for Key {
.map_err(|err| CryptoErrorKind::DataDecryptionFailed(err).into())
}

/// Returns the encrypted data from the given data.
/// Returns the encrypted+MACed data from the given data.
///
/// # Arguments
///
Expand Down
2 changes: 1 addition & 1 deletion crates/rustic_core/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl<BE: DecryptReadBackend> IndexBackend<BE> {
///
/// If the index could not be read
pub fn only_full_trees(be: &BE, p: &impl Progress) -> RusticResult<Self> {
Self::new_from_collector(be, p, IndexCollector::new(IndexType::FullTrees))
Self::new_from_collector(be, p, IndexCollector::new(IndexType::DataIds))
}

/// Convert the Arc<Index> to an Index
Expand Down
10 changes: 5 additions & 5 deletions crates/rustic_core/src/index/binarysorted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ pub(crate) struct SortedEntry {
pub enum IndexType {
/// Index everything.
Full,
// TODO: What is the difference between `FullTrees` and `Full`?
FullTrees,
/// Index only Ids for data blobs (+ full information for tree blobs)
DataIds,
/// Index only trees.
OnlyTrees,
}
Expand Down Expand Up @@ -83,7 +83,7 @@ impl IndexCollector {
collector.0[BlobType::Tree].entries = EntriesVariants::FullEntries(Vec::new());
collector.0[BlobType::Data].entries = match tpe {
IndexType::OnlyTrees => EntriesVariants::None,
IndexType::FullTrees => EntriesVariants::Ids(Vec::new()),
IndexType::DataIds => EntriesVariants::Ids(Vec::new()),
IndexType::Full => EntriesVariants::FullEntries(Vec::new()),
};

Expand Down Expand Up @@ -335,7 +335,7 @@ mod tests {

#[test]
fn all_index_types() {
for it in [IndexType::OnlyTrees, IndexType::FullTrees, IndexType::Full] {
for it in [IndexType::OnlyTrees, IndexType::DataIds, IndexType::Full] {
let index = index(it);

let id = parse("0000000000000000000000000000000000000000000000000000000000000000");
Expand Down Expand Up @@ -386,7 +386,7 @@ mod tests {

#[test]
fn full_trees() {
let index = index(IndexType::FullTrees);
let index = index(IndexType::DataIds);

let id = parse("fac5e908151e565267570108127b96e6bae22bcdda1d3d867f63ed1555fc8aef");
assert!(index.has(BlobType::Data, &id));
Expand Down
7 changes: 4 additions & 3 deletions crates/rustic_core/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,16 +969,17 @@ impl<P: ProgressBars, S: Open> Repository<P, S> {
}
}

// TODO: add documenation!
/// A repository which is indexed such that all tree blobs are contained in the index.
pub trait IndexedTree: Open {
type I: IndexedBackend;
fn index(&self) -> &Self::I;
}

// TODO: Repository is fully indexed
/// A repository which is indexed such that all tree blobs are contained in the index
/// and additionally the `Id`s of data blobs are also contained in the index.
pub trait IndexedIds: IndexedTree {}

// TODO: Repository is fully indexed
/// A repository which is indexed such that all blob information is fully contained in the index.
pub trait IndexedFull: IndexedIds {}

impl<P, S: IndexedTree> IndexedTree for Repository<P, S> {
Expand Down

0 comments on commit b570924

Please sign in to comment.