pub struct DkimSigningStream<'a, T: SigningKey> { /* private fields */ }Expand description
A streaming DKIM signer that allows signing messages in chunks.
This is useful when you want to avoid loading the entire message into memory before signing. Headers are buffered internally until the header/body boundary is detected, then body content is streamed through the hasher.
§Example
ⓘ
let signer = DkimSigner::from_key(key)
.domain("example.com")
.selector("default")
.headers(["From", "To", "Subject"]);
let mut stream = signer.sign_streaming();
stream.write(b"From: sender@example.com\r\n");
stream.write(b"To: recipient@example.com\r\n");
stream.write(b"Subject: Test\r\n");
stream.write(b"\r\n");
stream.write(b"Body content here...");
let signature = stream.finish()?;Implementations§
Source§impl<T: SigningKey> DkimSigningStream<'_, T>
impl<T: SigningKey> DkimSigningStream<'_, T>
Sourcepub fn write(&mut self, chunk: &[u8])
pub fn write(&mut self, chunk: &[u8])
Feed a chunk of raw message data to the signer.
Data should be provided in order, starting with headers. The header/body
boundary (\r\n\r\n) is automatically detected.
While reading headers, all data is buffered. Once the header/body boundary is detected, subsequent body data is streamed directly to the hasher.
Sourcepub fn finish(self) -> Result<Signature>
pub fn finish(self) -> Result<Signature>
Finalize the signature.
Consumes the stream and returns the DKIM signature. The current system
time is used for the t= timestamp.
§Errors
Returns an error if:
- No headers matching the signer’s header list were found
- The cryptographic signing operation fails
finish()was already called
Auto Trait Implementations§
impl<'a, T> Freeze for DkimSigningStream<'a, T>
impl<'a, T> RefUnwindSafe for DkimSigningStream<'a, T>
impl<'a, T> Send for DkimSigningStream<'a, T>
impl<'a, T> Sync for DkimSigningStream<'a, T>
impl<'a, T> Unpin for DkimSigningStream<'a, T>
impl<'a, T> UnsafeUnpin for DkimSigningStream<'a, T>
impl<'a, T> UnwindSafe for DkimSigningStream<'a, T>
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