pub struct PolicyEngine { /* private fields */ }Expand description
Policy engine for enforcing network policies
Implementations§
Source§impl PolicyEngine
impl PolicyEngine
Sourcepub fn new(config: PolicyConfig) -> Self
pub fn new(config: PolicyConfig) -> Self
Create a new policy engine
Sourcepub fn add_connection_policy(
&self,
policy: ConnectionPolicy,
) -> Result<(), PolicyError>
pub fn add_connection_policy( &self, policy: ConnectionPolicy, ) -> Result<(), PolicyError>
Add a connection policy
Sourcepub fn add_bandwidth_policy(
&self,
policy: BandwidthPolicy,
) -> Result<(), PolicyError>
pub fn add_bandwidth_policy( &self, policy: BandwidthPolicy, ) -> Result<(), PolicyError>
Add a bandwidth policy
Sourcepub fn add_content_policy(
&self,
policy: ContentPolicy,
) -> Result<(), PolicyError>
pub fn add_content_policy( &self, policy: ContentPolicy, ) -> Result<(), PolicyError>
Add a content policy
Sourcepub async fn evaluate_connection(
&self,
peer_id: &str,
) -> Result<bool, PolicyError>
pub async fn evaluate_connection( &self, peer_id: &str, ) -> Result<bool, PolicyError>
Evaluate a connection request
Sourcepub fn can_connect(&self, peer_id: &str) -> bool
pub fn can_connect(&self, peer_id: &str) -> bool
Check if a peer can establish a connection (with connection count check)
Sourcepub fn record_connection(&self, peer_id: &str)
pub fn record_connection(&self, peer_id: &str)
Record a connection
Sourcepub fn record_disconnection(&self, peer_id: &str)
pub fn record_disconnection(&self, peer_id: &str)
Record a disconnection
Sourcepub fn remove_connection_policy(&self, name: &str) -> Result<(), PolicyError>
pub fn remove_connection_policy(&self, name: &str) -> Result<(), PolicyError>
Remove a connection policy
Sourcepub fn connection_policies(&self) -> Vec<ConnectionPolicy>
pub fn connection_policies(&self) -> Vec<ConnectionPolicy>
Get all connection policies
Sourcepub fn bandwidth_policies(&self) -> Vec<BandwidthPolicy>
pub fn bandwidth_policies(&self) -> Vec<BandwidthPolicy>
Get all bandwidth policies
Sourcepub fn content_policies(&self) -> Vec<ContentPolicy>
pub fn content_policies(&self) -> Vec<ContentPolicy>
Get all content policies
Sourcepub fn stats(&self) -> PolicyStats
pub fn stats(&self) -> PolicyStats
Get statistics
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset statistics
Auto Trait Implementations§
impl Freeze for PolicyEngine
impl !RefUnwindSafe for PolicyEngine
impl Send for PolicyEngine
impl Sync for PolicyEngine
impl Unpin for PolicyEngine
impl !UnwindSafe for PolicyEngine
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more