SignWith

Trait SignWith 

Source
pub trait SignWith: Sized {
    // Required method
    fn sign_with_sync(self, signer: &dyn Signer) -> Result<Bytes, TrustError>;
}
Expand description

Extension trait that adds a high-level sign_with method to packet builders.

Extracts the signature algorithm and key locator from the signer automatically, eliminating the need to pass them explicitly.

§Example

use ndn_packet::encode::DataBuilder;
use ndn_security::{KeyChain, SignWith};

let kc = KeyChain::ephemeral("/com/example/alice")?;
let signer = kc.signer()?;

let wire = DataBuilder::new("/com/example/alice/data", b"hello")
    .sign_with_sync(&*signer)?;

Required Methods§

Source

fn sign_with_sync(self, signer: &dyn Signer) -> Result<Bytes, TrustError>

Sign this packet using the given signer (synchronous).

The signature algorithm and key locator name are taken from signer. Use this for Ed25519 and HMAC-SHA256 signers, which are always CPU-bound and have fast synchronous paths.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SignWith for DataBuilder

Source§

fn sign_with_sync(self, signer: &dyn Signer) -> Result<Bytes, TrustError>

Source§

impl SignWith for InterestBuilder

Source§

fn sign_with_sync(self, signer: &dyn Signer) -> Result<Bytes, TrustError>

Implementors§