pub struct GatewayBridge { /* private fields */ }Expand description
Gateway-bridge helper.
Lifecycle:
GatewayBridge::newwithGatewayBridgeConfig.- Optional
GatewayBridge::with_upstreamto hook the own bridge into an existing chain (e.g. from the hull GW to the own turret GW). - Per edge:
GatewayBridge::delegate_forto issue a new delegation. GatewayBridge::chain_forprovides the chain as output for SPDP/SEDP properties.GatewayBridge::revoke_delegationremoves an edge.
Implementations§
Source§impl GatewayBridge
impl GatewayBridge
Sourcepub fn new(config: GatewayBridgeConfig) -> Self
pub fn new(config: GatewayBridgeConfig) -> Self
Constructor.
Sourcepub fn with_upstream(&mut self, upstream_chain: DelegationChain)
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.
Sourcepub fn gateway_guid(&self) -> [u8; 16]
pub fn gateway_guid(&self) -> [u8; 16]
16-byte gateway GUID (read-only).
Sourcepub 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>
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).
Sourcepub fn revoke_delegation(
&mut self,
edge_guid: [u8; 16],
) -> GatewayBridgeResult<()>
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.
Sourcepub fn chain_for(&self, edge_guid: &[u8; 16]) -> Option<DelegationChain>
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.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Number of active edge delegations.
Sourcepub fn iter_active(&self) -> impl Iterator<Item = (&[u8; 16], &DelegationLink)>
pub fn iter_active(&self) -> impl Iterator<Item = (&[u8; 16], &DelegationLink)>
Iterates over all active edge delegations.
Sourcepub fn take_revocations(&mut self) -> Vec<[u8; 16]>
pub fn take_revocations(&mut self) -> Vec<[u8; 16]>
Reads and clears the revocation list (the discovery layer calls this per SPDP beacon tick).
Sourcepub fn upstream(&self) -> Option<&DelegationChain>
pub fn upstream(&self) -> Option<&DelegationChain>
Read access to the upstream chain (useful for logging / metrics).
Sourcepub 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)>)
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)>)
Rotates ephemeral edge identities whose lifetime has expired.
Workflow per ephemeral edge:
- If the edge is not active → skip (init comes via
delegate_forby the caller). - If
now < link.not_after - lifetime/N(N=renewal window) → still too fresh, skip. - Otherwise: pull a new GuidPrefix (
prefix_generator(name)), revoke the old edge, issue a newdelegate_forwith anow-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
impl Clone for GatewayBridge
Source§fn clone(&self) -> GatewayBridge
fn clone(&self) -> GatewayBridge
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more