pub struct Signer { /* private fields */ }Expand description
Builder for signing operations.
§Examples
Basic signing:
use libsignify_rs::{KeyGenerator, Signer};
use tempfile::tempdir;
use std::fs;
let dir = tempdir()?;
let pub_path = dir.path().join("key.pub");
let sec_path = dir.path().join("key.sec");
let msg_path = dir.path().join("msg.txt");
let sig_path = dir.path().join("msg.sig");
// Setup: Generate keys and message
KeyGenerator::new().rounds(0).generate(&pub_path, &sec_path)?;
fs::write(&msg_path, "test message")?;
// Sign
Signer::new()
.seckey(&sec_path)
.sign(&msg_path, &sig_path)?;
assert!(sig_path.exists());Embedded signature:
Signer::new()
.seckey(&sec_path)
.embed(true)
.sign(&msg_path, &sig_path)?;Gzip signing:
use flate2::write::GzEncoder;
use flate2::Compression;
use std::fs::File;
use std::io::Write;
// Create a valid gzip file to sign
let f = File::create(&msg_path)?;
let mut e = GzEncoder::new(f, Compression::default());
e.write_all(b"compressed content")?;
e.finish()?;
Signer::new()
.seckey(&sec_path)
.gzip(true)
.sign(&msg_path, &sig_path)?;Implementations§
Source§impl Signer
impl Signer
Sourcepub fn tty_handle(self, tty: File) -> Self
pub fn tty_handle(self, tty: File) -> Self
Set TTY handle for interactive password prompts.
Sourcepub fn embed(self, embed: bool) -> Self
pub fn embed(self, embed: bool) -> Self
Set embed mode (signify -e).
If true, creates an embedded signature.
Sourcepub fn gzip(self, gzip: bool) -> Self
pub fn gzip(self, gzip: bool) -> Self
Set gzip mode (signify -z).
If true, signs a gzip archive.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Signer
impl RefUnwindSafe for Signer
impl Send for Signer
impl Sync for Signer
impl Unpin for Signer
impl UnwindSafe for Signer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more