Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/crypto_write_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn main() -> Result<()> {
let mut file = File::open(path_in.clone())?;
let mut writer = crypto::create_write(File::create(out.clone())?, cipher, &key);
info!("encrypt file");
io::copy(&mut file, &mut writer).unwrap();
io::copy(&mut file, &mut writer)?;
writer.finish()?;

let mut reader = crypto::create_read(File::open(out)?, cipher, &key);
Expand Down
6 changes: 3 additions & 3 deletions examples/file_handling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct PasswordProviderImpl;

impl PasswordProvider for PasswordProviderImpl {
fn get_password(&self) -> Option<SecretString> {
Some(SecretString::from_str("password").unwrap())
Some(SecretString::from_str("password")?)
}
}

Expand All @@ -39,7 +39,7 @@ async fn main() -> Result<()> {
)
.await?;

let file_name = SecretString::from_str("file1").unwrap();
let file_name = SecretString::from_str("file1")?;
let (file_handle, attr) = fs
.create(ROOT_INODE, &file_name, file_attributes(), false, true)
.await?;
Expand All @@ -66,7 +66,7 @@ async fn main() -> Result<()> {
Ok(())
}

const fn file_attributes() -> CreateFileAttr {
fn file_attributes() -> CreateFileAttr {
CreateFileAttr {
kind: FileType::RegularFile,
perm: 0o644, // Permissions
Expand Down
5 changes: 3 additions & 2 deletions examples/internal_ring.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use ring::aead::{Aad, LessSafeKey, Nonce, UnboundKey, CHACHA20_POLY1305};

fn main() {
fn main() -> Result<(), Box<dyn std::error::Error>> {
let key = [42; 32];
let nonce_data = [124; 12]; // Just an example
let mut data = b"hello, this is my secret message".to_vec();

let key = UnboundKey::new(&CHACHA20_POLY1305, &key).unwrap();
let key = UnboundKey::new(&CHACHA20_POLY1305, &key)?;
let key = LessSafeKey::new(key);
println!("{data:?}");

Expand All @@ -19,4 +19,5 @@ fn main() {
let nonce = Nonce::assume_unique_for_key(nonce_data);
let data = key.open_in_place(nonce, Aad::empty(), &mut data).unwrap();
println!("{data:?}");
Ok(())
}
2 changes: 1 addition & 1 deletion examples/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async fn main() -> Result<()> {
impl PasswordProvider for PasswordProviderImpl {
fn get_password(&self) -> Option<SecretString> {
// dummy password, use some secure way to get the password like with [keyring](https://crates.io/crates/keyring) crate
Some(SecretString::from_str("a").unwrap())
Some(SecretString::from_str("a")?)
}
}
let mount_point = create_mount_point(
Expand Down
2 changes: 1 addition & 1 deletion examples/wal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn main() -> io::Result<()> {

// We can use the previously returned DataRecord to read the original data.
let mut reader = log.read_at(record.position)?;
let mut buffer = vec![0; usize::try_from(record.length).unwrap()];
let mut buffer = vec![0; usize::try_from(record.length)?];
reader.read_exact(&mut buffer)?;
println!(
"Data read from log: {}",
Expand Down