Skip to main content

Destination

Struct Destination 

Source
pub struct Destination {
    pub hash: DestHash,
    pub dest_type: DestinationType,
    pub direction: Direction,
    pub app_name: String,
    pub aspects: Vec<String>,
    pub identity_hash: Option<IdentityHash>,
    pub public_key: Option<[u8; 64]>,
    pub group_key: Option<Vec<u8>>,
    pub proof_strategy: ProofStrategy,
}
Expand description

A network destination (endpoint) for sending or receiving packets.

This is a pure data struct with no behavior — all operations (register, announce, send) are methods on RnsNode.

Fields§

§hash: DestHash

Computed destination hash.

§dest_type: DestinationType

Type: Single, Group, or Plain.

§direction: Direction

Direction: In (receiving) or Out (sending).

§app_name: String

Application name (e.g. “echo_app”).

§aspects: Vec<String>

Aspects (e.g. [“echo”, “request”]).

§identity_hash: Option<IdentityHash>

Identity hash of the owner (for SINGLE destinations).

§public_key: Option<[u8; 64]>

Full public key (64 bytes) of the remote peer (for OUT SINGLE destinations).

§group_key: Option<Vec<u8>>

Symmetric key for GROUP destinations (32 or 64 bytes).

§proof_strategy: ProofStrategy

How to handle proofs for incoming packets.

Implementations§

Source§

impl Destination

Source

pub fn single_in( app_name: &str, aspects: &[&str], identity_hash: IdentityHash, ) -> Self

Create an inbound SINGLE destination (for receiving encrypted packets).

identity_hash is the local identity that owns this destination.

Source

pub fn single_out( app_name: &str, aspects: &[&str], recalled: &AnnouncedIdentity, ) -> Self

Create an outbound SINGLE destination (for sending encrypted packets).

recalled contains the remote peer’s identity data (from announce/recall).

Source

pub fn plain(app_name: &str, aspects: &[&str]) -> Self

Create a PLAIN destination (unencrypted, no identity).

Source

pub fn group(app_name: &str, aspects: &[&str]) -> Self

Create a GROUP destination (symmetric encryption with pre-shared key).

No identity needed — the hash is based only on app_name + aspects, same as PLAIN. All members sharing the same key can encrypt/decrypt.

Source

pub fn create_keys(&mut self)

Generate a new random 64-byte symmetric key (AES-256) for this GROUP destination.

Source

pub fn load_private_key(&mut self, key: Vec<u8>) -> Result<(), GroupKeyError>

Load an existing symmetric key for this GROUP destination.

Key must be 32 bytes (AES-128) or 64 bytes (AES-256).

Source

pub fn get_private_key(&self) -> Option<&[u8]>

Retrieve the symmetric key bytes, if set.

Source

pub fn encrypt(&self, plaintext: &[u8]) -> Result<Vec<u8>, GroupKeyError>

Encrypt plaintext using this destination’s GROUP key.

Source

pub fn decrypt(&self, ciphertext: &[u8]) -> Result<Vec<u8>, GroupKeyError>

Decrypt ciphertext using this destination’s GROUP key.

Source

pub fn set_proof_strategy(self, strategy: ProofStrategy) -> Self

Set the proof strategy for this destination.

Trait Implementations§

Source§

impl Clone for Destination

Source§

fn clone(&self) -> Destination

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Destination

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.