pub struct NetworkPolicy {
pub default_action: Action,
pub rules: Vec<Rule>,
}Expand description
Network policy with ordered rules.
Rules are evaluated in first-match-wins order. If no rule matches, the default action is applied.
Fields§
§default_action: ActionDefault action for traffic not matching any rule.
rules: Vec<Rule>Ordered list of rules (first match wins).
Implementations§
Source§impl NetworkPolicy
impl NetworkPolicy
Sourcepub fn public_only() -> Self
pub fn public_only() -> Self
Public internet only — deny loopback, private, link-local, and cloud metadata addresses.
Sourcepub fn evaluate_egress(&self, dst: SocketAddr, protocol: Protocol) -> Action
pub fn evaluate_egress(&self, dst: SocketAddr, protocol: Protocol) -> Action
Evaluate an outbound connection against the policy.
Returns the action from the first matching rule, or the default action if no rule matches.
Sourcepub fn evaluate_egress_ip(&self, dst: IpAddr, protocol: Protocol) -> Action
pub fn evaluate_egress_ip(&self, dst: IpAddr, protocol: Protocol) -> Action
Evaluate an outbound ICMP packet against the policy.
Same first-match-wins logic as Self::evaluate_egress but without port
matching — ICMP has no ports. Rules with a ports filter are
skipped since applying a port range to a portless protocol would
be semantically incorrect.
Trait Implementations§
Source§impl Clone for NetworkPolicy
impl Clone for NetworkPolicy
Source§fn clone(&self) -> NetworkPolicy
fn clone(&self) -> NetworkPolicy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NetworkPolicy
impl Debug for NetworkPolicy
Source§impl Default for NetworkPolicy
impl Default for NetworkPolicy
Source§impl<'de> Deserialize<'de> for NetworkPolicy
impl<'de> Deserialize<'de> for NetworkPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for NetworkPolicy
impl RefUnwindSafe for NetworkPolicy
impl Send for NetworkPolicy
impl Sync for NetworkPolicy
impl Unpin for NetworkPolicy
impl UnsafeUnpin for NetworkPolicy
impl UnwindSafe for NetworkPolicy
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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