pub struct NetworkPolicyDecider { /* private fields */ }Expand description
Glue type that bundles a NetworkPolicy with a session cache and an
auditor. Tools call NetworkPolicyDecider::evaluate before any HTTP
transport is constructed; the result decides whether to proceed, deny,
or prompt the user.
Implementations§
Source§impl NetworkPolicyDecider
impl NetworkPolicyDecider
Sourcepub fn new(
policy: NetworkPolicy,
auditor: Option<NetworkAuditor>,
) -> NetworkPolicyDecider
pub fn new( policy: NetworkPolicy, auditor: Option<NetworkAuditor>, ) -> NetworkPolicyDecider
Build a decider from a policy. The session cache starts empty.
Sourcepub fn with_default_audit(policy: NetworkPolicy) -> NetworkPolicyDecider
pub fn with_default_audit(policy: NetworkPolicy) -> NetworkPolicyDecider
Convenience: build a decider with default audit logging at
~/.deepseek/audit.log, if policy.audit is true.
Sourcepub fn policy(&self) -> &NetworkPolicy
pub fn policy(&self) -> &NetworkPolicy
Inspect the policy.
Sourcepub fn cache(&self) -> &NetworkSessionCache
pub fn cache(&self) -> &NetworkSessionCache
Inspect the session cache.
Sourcepub fn evaluate(&self, host: &str, tool: &str) -> Decision
pub fn evaluate(&self, host: &str, tool: &str) -> Decision
Decide for host, consulting the session cache first.
Audit logging happens only for terminal decisions (Allow / Deny).
Prompt is intentionally not logged here — the caller is responsible
for recording the user’s eventual answer with record_prompt_outcome.
Sourcepub fn approve_session(&self, host: &str, tool: &str)
pub fn approve_session(&self, host: &str, tool: &str)
Approve host for the rest of the session (one-shot). Audit log gets
Prompt-Approved.
Sourcepub fn deny_session(&self, host: &str, tool: &str)
pub fn deny_session(&self, host: &str, tool: &str)
Deny host for the rest of the session. Audit log gets Prompt-Denied.
Sourcepub fn approve_persistent(&mut self, host: &str, tool: &str) -> &NetworkPolicy
pub fn approve_persistent(&mut self, host: &str, tool: &str) -> &NetworkPolicy
Persist host into the policy’s allow list (so it survives the session)
and approve it in-session. Returns the updated policy so callers can
write it back to disk.
Trait Implementations§
Source§impl Clone for NetworkPolicyDecider
impl Clone for NetworkPolicyDecider
Source§fn clone(&self) -> NetworkPolicyDecider
fn clone(&self) -> NetworkPolicyDecider
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for NetworkPolicyDecider
impl RefUnwindSafe for NetworkPolicyDecider
impl Send for NetworkPolicyDecider
impl Sync for NetworkPolicyDecider
impl Unpin for NetworkPolicyDecider
impl UnsafeUnpin for NetworkPolicyDecider
impl UnwindSafe for NetworkPolicyDecider
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
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>
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