pub enum RuleSource {
Policy,
User,
Project,
Session,
Default,
}Expand description
规则来源 — 5 层优先级,高优先级来源的决策不可被低优先级覆盖。
Policy (最高) → User → Project → Session → Default (最低)§设计参考
- Claude-Code: 7 种来源
- OpenCode: 无来源概念(flat ruleset)
- katu: 5 层,兼顾灵活性与简洁性
§Examples
use katu_core::permission::RuleSource;
assert!(RuleSource::Policy.priority() > RuleSource::User.priority());
assert!(RuleSource::User.priority() > RuleSource::Project.priority());Variants§
Policy
管理员策略 — 最高优先级,不可被用户覆盖。
来自企业管理平台或 policySettings。
User
用户全局设置 — 用户级偏好。
来自 ~/.config/katu/settings.toml。
Project
项目设置 — 项目级偏好。
来自 .katu/settings.toml(版本控制中共享)。
Session
会话 / 运行时 — 本次运行中动态添加的规则。
来自用户 “always allow” 选择或命令行参数。
Default
默认规则 — 最低优先级,内置兜底。
Implementations§
Source§impl RuleSource
impl RuleSource
Trait Implementations§
Source§impl Clone for RuleSource
impl Clone for RuleSource
Source§fn clone(&self) -> RuleSource
fn clone(&self) -> RuleSource
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 RuleSource
impl Debug for RuleSource
Source§impl<'de> Deserialize<'de> for RuleSource
impl<'de> Deserialize<'de> for RuleSource
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
Source§impl Hash for RuleSource
impl Hash for RuleSource
Source§impl Ord for RuleSource
impl Ord for RuleSource
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for RuleSource
impl PartialEq for RuleSource
Source§fn eq(&self, other: &RuleSource) -> bool
fn eq(&self, other: &RuleSource) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for RuleSource
impl PartialOrd for RuleSource
Source§impl Serialize for RuleSource
impl Serialize for RuleSource
impl Copy for RuleSource
impl Eq for RuleSource
impl StructuralPartialEq for RuleSource
Auto Trait Implementations§
impl Freeze for RuleSource
impl RefUnwindSafe for RuleSource
impl Send for RuleSource
impl Sync for RuleSource
impl Unpin for RuleSource
impl UnsafeUnpin for RuleSource
impl UnwindSafe for RuleSource
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
Mutably borrows from an owned value. Read more