Skip to main content

PluginPolicy

Struct PluginPolicy 

Source
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: FrameworkId

Framework whose manifests this policy governs. 本策略所管辖 manifest 的目标框架。

§allow_official: bool

Whether official-sourced manifests may be selected. 是否允许选中官方来源的 manifest。

§allow_user: bool

Whether user-sourced manifests may be selected. 是否允许选中用户来源的 manifest。

§require_digest: bool

Reject manifests whose checksum is not a cryptographic digest. 拒绝不是密码学摘要的插件 manifest。

Implementations§

Source§

impl PluginPolicy

Source

pub const fn local(framework: FrameworkId) -> PluginPolicy

Deny every source; for hosts that link no external plugin. 拒绝所有来源;供不链接外部插件的宿主使用。

Source

pub const fn open(framework: FrameworkId) -> PluginPolicy

Admit both official and user sources without a digest requirement. 同时接受官方与用户来源,且不要求密码学摘要。

Source

pub const fn strict(framework: FrameworkId) -> PluginPolicy

Open policy with cryptographic checksum enforcement enabled. 开放来源但强制校验密码学摘要的策略。

Source

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 仅凭自述就被接纳。

Source

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

Source§

fn clone(&self) -> PluginPolicy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PluginPolicy

Source§

impl Debug for PluginPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for PluginPolicy

Source§

impl PartialEq for PluginPolicy

Source§

fn eq(&self, other: &PluginPolicy) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PluginPolicy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.