pub struct PluginPolicy {
pub framework: FrameworkId,
pub allow_official: bool,
pub allow_user: bool,
pub require_digest: bool,
}Expand description
Host policy for selecting which linked plugin manifests may participate. 宿主选择已链接插件是否参与的策略。
Fields§
§framework: FrameworkIdFramework whose manifests this policy governs. 本策略所管辖 manifest 的目标框架。
allow_official: boolWhether official-sourced manifests may be selected. 是否允许选中官方来源的 manifest。
allow_user: boolWhether user-sourced manifests may be selected. 是否允许选中用户来源的 manifest。
require_digest: boolReject manifests whose checksum is not a cryptographic digest. 拒绝不是密码学摘要的插件 manifest。
Implementations§
Source§impl PluginPolicy
impl PluginPolicy
Sourcepub const fn local(framework: FrameworkId) -> PluginPolicy
pub const fn local(framework: FrameworkId) -> PluginPolicy
Deny every source; for hosts that link no external plugin. 拒绝所有来源;供不链接外部插件的宿主使用。
Sourcepub const fn open(framework: FrameworkId) -> PluginPolicy
pub const fn open(framework: FrameworkId) -> PluginPolicy
Admit both official and user sources without a digest requirement. 同时接受官方与用户来源,且不要求密码学摘要。
Sourcepub const fn strict(framework: FrameworkId) -> PluginPolicy
pub const fn strict(framework: FrameworkId) -> PluginPolicy
Open policy with cryptographic checksum enforcement enabled. 开放来源但强制校验密码学摘要的策略。
Sourcepub fn accepts(
self,
plugin: PluginManifest,
catalog: Option<&PluginCatalog>,
) -> bool
pub fn accepts( self, plugin: PluginManifest, catalog: Option<&PluginCatalog>, ) -> bool
Whether the manifest is admitted, collapsing the reason to a boolean. 该 manifest 是否被接纳;原因被折叠成一个布尔值。
catalog is the host’s official lock record. Pass it whenever the host
has one: an official manifest is only compared against the lock when a
catalog is supplied, so None skips that check. The predicate takes the
catalog rather than assuming it away because the old form hardcoded
None, which made PluginRejectReason::LockMismatch unreachable for
every caller — a self-declared Official manifest was admitted on its
own word.
catalog 是宿主的官方锁记录;宿主手上有它就应当传入:只有提供目录时,官方 manifest 才会
与锁记录比对,None 会跳过该检查。本谓词把目录作为参数、而不是假称它不存在,因为旧写法
硬编码 None,使 PluginRejectReason::LockMismatch 对每个调用方都不可达——一个自称
Official 的 manifest 仅凭自述就被接纳。
Sourcepub fn decision(
self,
plugin: PluginManifest,
catalog: Option<&PluginCatalog>,
) -> PluginDecision
pub fn decision( self, plugin: PluginManifest, catalog: Option<&PluginCatalog>, ) -> PluginDecision
Explain selection instead of silently dropping a linked plugin. 返回筛选原因,不再让已链接插件静默消失。
Trait Implementations§
Source§impl Clone for PluginPolicy
impl Clone for PluginPolicy
Source§fn clone(&self) -> PluginPolicy
fn clone(&self) -> PluginPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more