@@ -77,10 +77,7 @@ pub const AES_IV_LENGTH: usize = 16;
7777/// # Example
7878///
7979/// ```rust
80- /// use tee_worker_post_compute::compute::{
81- /// encryption::encrypt_data,
82- /// errors::ReplicateStatusCause,
83- /// };
80+ /// use tee_worker_post_compute::compute::encryption::encrypt_data;
8481///
8582/// const TEST_RSA_PUBLIC_KEY_PEM: &str = r#"-----BEGIN PUBLIC KEY-----
8683/// MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr0mx20CSFczJaM4rtYfL
@@ -92,18 +89,26 @@ pub const AES_IV_LENGTH: usize = 16;
9289/// FQIDAQAB
9390/// -----END PUBLIC KEY-----"#;
9491///
95- /// fn main() -> Result<(), ReplicateStatusCause> {
96- /// let temp_file = tempfile::NamedTempFile::new().expect("Failed to create temp file");
97- /// std::fs::write(temp_file.path(), b"Super secret data").expect("Failed to write to temp file");
98- /// let file = temp_file.path().to_str().unwrap();
99- /// // Encrypt a file and create a ZIP archive
100- /// let result = encrypt_data(file, TEST_RSA_PUBLIC_KEY_PEM, true)?;
101- /// println!("Encrypted ZIP created: {}", result);
102- ///
103- /// // Encrypt a file and get directory path
104- /// let result = encrypt_data(file, TEST_RSA_PUBLIC_KEY_PEM, false)?;
105- /// println!("Encrypted files in: {}", result);
106- /// Ok(())
92+ /// let temp_file = tempfile::NamedTempFile::new().expect("Failed to create temp file");
93+ /// match std::fs::write(temp_file.path(), b"Super secret data") {
94+ /// Ok(_) => println!("Successfully wrote to temp file"),
95+ /// Err(e) => eprintln!("Failed to write to temp file: {}", e),
96+ /// }
97+ /// let file = match temp_file.path().to_str() {
98+ /// Some(f) => f,
99+ /// _ => "error_converting_temp_file_path_to_string",
100+ /// };
101+ ///
102+ /// // Encrypt a file and create a ZIP archive
103+ /// match encrypt_data(file, TEST_RSA_PUBLIC_KEY_PEM, true) {
104+ /// Ok(result) => println!("Encrypted ZIP created: {}", result),
105+ /// Err(e) => eprintln!("Failed to encrypt file and create ZIP archive: {:?}", e),
106+ /// }
107+ ///
108+ /// // Encrypt a file and do not create a ZIP archive
109+ /// match encrypt_data(file, TEST_RSA_PUBLIC_KEY_PEM, false) {
110+ /// Ok(result) => println!("Encrypted files in: {}", result),
111+ /// Err(e) => eprintln!("Failed to encrypt file and create directory: {:?}", e),
107112/// }
108113/// ```
109114pub fn encrypt_data (
0 commit comments