pub struct ConsentManager { /* private fields */ }Expand description
Implementations§
Source§impl ConsentManager
impl ConsentManager
Sourcepub fn new() -> ConsentManager
pub fn new() -> ConsentManager
Create a new consent manager, resolving the default path under
dirs::config_dir()/oxicode/mcp-consent.json.
Sourcepub fn with_path(persist_path: PathBuf) -> ConsentManager
pub fn with_path(persist_path: PathBuf) -> ConsentManager
Create a manager with a custom file path (used by tests).
Sourcepub fn load(&self) -> Result<(), Error>
pub fn load(&self) -> Result<(), Error>
Load decisions from disk. Missing file is not an error.
Sourcepub fn check(&self, name: &str) -> ConsentState
pub fn check(&self, name: &str) -> ConsentState
Look up the consent for a given name. Defaults to Allow.
Sourcepub fn check_spawn_consent(&self, name: &str) -> ConsentState
pub fn check_spawn_consent(&self, name: &str) -> ConsentState
Spawn-path consent check. Unknown servers return Ask (the caller
treats Ask and Deny identically: deny the spawn and surface
McpError::ConsentDenied). This is deliberately a separate
default from check so the per-tool gate at
direct_tool.rs (which only blocks Deny) is unaffected.
Sourcepub fn decide(&self, name: &str, state: ConsentState) -> Result<(), Error>
pub fn decide(&self, name: &str, state: ConsentState) -> Result<(), Error>
Persist a consent decision. name is a tool or server name.
Ask is normalized to Deny — it is a transient runtime signal,
never a stored state (see the module docs). Callers that resolve
Ask interactively must pass the resolved Allow/Deny here.
Sourcepub fn trust(&self, name: &str) -> Result<(), Error>
pub fn trust(&self, name: &str) -> Result<(), Error>
Trust a server (persist Allow). Convenience wrapper around
decide. Used by oxicode mcp trust <server>.
Sourcepub fn untrust(&self, name: &str) -> Result<(), Error>
pub fn untrust(&self, name: &str) -> Result<(), Error>
Revoke trust for a server (persist Deny). Convenience wrapper
around decide. Used by oxicode mcp untrust <server>.
Sourcepub fn all_decisions(&self) -> HashMap<String, ConsentState>
pub fn all_decisions(&self) -> HashMap<String, ConsentState>
All current decisions (for the TUI dashboard).
Trait Implementations§
Source§impl Debug for ConsentManager
impl Debug for ConsentManager
Source§impl Default for ConsentManager
impl Default for ConsentManager
Source§fn default() -> ConsentManager
fn default() -> ConsentManager
Auto Trait Implementations§
impl !Freeze for ConsentManager
impl !RefUnwindSafe for ConsentManager
impl Send for ConsentManager
impl Sync for ConsentManager
impl Unpin for ConsentManager
impl UnsafeUnpin for ConsentManager
impl UnwindSafe for ConsentManager
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.