Skip to main content

GatewayBridge

Struct GatewayBridge 

Source
pub struct GatewayBridge { /* private fields */ }
Expand description

Gateway-bridge helper.

Lifecycle:

  1. GatewayBridge::new with GatewayBridgeConfig.
  2. Optional GatewayBridge::with_upstream to hook the own bridge into an existing chain (e.g. from the hull GW to the own turret GW).
  3. Per edge: GatewayBridge::delegate_for to issue a new delegation.
  4. GatewayBridge::chain_for provides the chain as output for SPDP/SEDP properties.
  5. GatewayBridge::revoke_delegation removes an edge.

Implementations§

Source§

impl GatewayBridge

Source

pub fn new(config: GatewayBridgeConfig) -> Self

Constructor.

Source

pub fn with_upstream(&mut self, upstream_chain: DelegationChain)

Sets an upstream chain. In Self::chain_for it is prepended to the edge link — sub-gateway chaining for a double-star (turret GW under hull GW).

Validation of the upstream chain is NOT part of the bridge — the caller must call validate_chain itself beforehand, to prevent mismatch-profile errors.

Source

pub fn gateway_guid(&self) -> [u8; 16]

16-byte gateway GUID (read-only).

Source

pub fn delegate_for( &mut self, edge_guid: [u8; 16], topic_patterns: Vec<String>, partition_patterns: Vec<String>, not_before: i64, not_after: i64, ) -> GatewayBridgeResult<&DelegationLink>

Issues a new delegation for an edge peer. If the edge was already delegated, the old link is overwritten (typical with ephemeral-edge rotation, plan §stage j-f).

not_before and not_after are absolute Unix seconds; topic_patterns/partition_patterns are the glob whitelist that the edge may have in the narrowest scope.

§Errors

GatewayBridgeError::DelegationFailed if the PKI sign step fails (cap violation, key parse error).

Source

pub fn revoke_delegation( &mut self, edge_guid: [u8; 16], ) -> GatewayBridgeResult<()>

Revokes the active delegation for an edge. The edge is added to the revocation list and can be communicated to the discovery layer via Self::take_revocations.

§Errors

GatewayBridgeError::UnknownEdge if the edge is not active.

Source

pub fn chain_for(&self, edge_guid: &[u8; 16]) -> Option<DelegationChain>

Returns the outgoing chain for an edge.

1-hop bridge (no upstream): chain = [edge link], origin_guid = gateway_guid. n-hop bridge (with upstream): chain = upstream.links ++ [edge link], origin_guid = upstream.origin_guid.

Returns None if the edge is not active.

Source

pub fn active_count(&self) -> usize

Number of active edge delegations.

Source

pub fn has_edge(&self, edge_guid: &[u8; 16]) -> bool

True if an edge is actively delegated.

Source

pub fn iter_active(&self) -> impl Iterator<Item = (&[u8; 16], &DelegationLink)>

Iterates over all active edge delegations.

Source

pub fn take_revocations(&mut self) -> Vec<[u8; 16]>

Reads and clears the revocation list (the discovery layer calls this per SPDP beacon tick).

Source

pub fn upstream(&self) -> Option<&DelegationChain>

Read access to the upstream chain (useful for logging / metrics).

Source

pub fn rotate_ephemerals<F>( &mut self, identities: &[EdgeIdentityConfig], now: i64, topic_patterns: Vec<String>, partition_patterns: Vec<String>, prefix_generator: F, ) -> (Vec<String>, Vec<(String, GatewayBridgeError)>)
where F: FnMut(&str) -> [u8; 12],

Rotates ephemeral edge identities whose lifetime has expired.

Workflow per ephemeral edge:

  1. If the edge is not active → skip (init comes via delegate_for by the caller).
  2. If now < link.not_after - lifetime/N (N=renewal window) → still too fresh, skip.
  3. Otherwise: pull a new GuidPrefix (prefix_generator(name)), revoke the old edge, issue a new delegate_for with a now-based time window.

prefix_generator is a pluggable hook (e.g. a ChaCha20 RNG or a system RNG); the bridge is deterministically testable because the randomness source comes from the caller.

Returns the list of rotated edge names.

§Errors

Propagates GatewayBridgeError::DelegationFailed if a re-sign fails — but does NOT abort the loop; faulty edges are collected in the Err tail vec and the caller can decide.

Trait Implementations§

Source§

impl Clone for GatewayBridge

Source§

fn clone(&self) -> GatewayBridge

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for GatewayBridge

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.