Skip to content

Commit 4c6dc8c

Browse files
committed
Add docs
1 parent 3aba612 commit 4c6dc8c

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
1010
#![deny(rustdoc::broken_intra_doc_links)]
1111
#![deny(rustdoc::private_intra_doc_links)]
12+
#![deny(missing_docs)]
1213

1314
/// Implements a thin-client ([`client::VssClient`]) to access a hosted instance of Versioned Storage Service (VSS).
1415
pub mod client;

src/util/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
/// Contains [StorableBuilder] helper utility.
2+
///
3+
/// [StorableBuilder]: storable_builder::StorableBuilder
14
pub mod storable_builder;

src/util/storable_builder.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,23 @@ use std::borrow::Borrow;
77
use std::io;
88
use std::io::{Error, ErrorKind};
99

10+
/// [`StorableBuilder`] is a helper utility to build and deconstruct [`Storable`] objects.
11+
/// It provides client-side `Encrypt-then-MAC` using ChaCha20-Poly1305.
1012
pub struct StorableBuilder {
1113
data_encryption_key: [u8; 32],
1214
}
1315

1416
const CHACHA20_CIPHER_NAME: &'static str = "ChaCha20Poly1305";
1517

1618
impl StorableBuilder {
19+
20+
/// Creates a [`Storable`] that can be serialized and stored as `value` in [PutObjectRequest].
21+
///
22+
/// Uses ChaCha20 for encrypting the `input` and Poly1305 for generating mac/tag.
23+
///
24+
/// Refer to docs on [`Storable`] for more information.
25+
///
26+
/// [PutObjectRequest]: crate::types::PutObjectRequest
1727
pub fn build(&self, input: Vec<u8>, version: i64) -> Storable {
1828
let mut rng = ThreadRng::default();
1929
let mut nonce = [0u8; 12];
@@ -34,6 +44,10 @@ impl StorableBuilder {
3444
}
3545
}
3646

47+
/// Deconstructs the provided [`Storable`] and returns constituent decrypted data and it's
48+
/// corresponding version as stored at the time of [PutObjectRequest].
49+
///
50+
/// [PutObjectRequest]: crate::types::PutObjectRequest
3751
pub fn deconstruct(&self, mut storable: Storable) -> io::Result<(Vec<u8>, i64)> {
3852
let encryption_metadata = storable.encryption_metadata.unwrap();
3953
let mut cipher = ChaCha20Poly1305::new(&self.data_encryption_key, &encryption_metadata.nonce, &[]);

0 commit comments

Comments
 (0)