pub struct CapabilityManifest {
pub version: u16,
pub tools: [u64; 128],
pub resources: [u64; 16],
pub prompts: [u64; 8],
pub extensions: u64,
pub signature: [u8; 64],
/* private fields */
}Expand description
Pre-computed capability manifest
Uses bitsets for efficient capability representation and intersection.
- tools: 8192 bits (128 × u64) = supports up to 8192 tools
- resources: 1024 bits (16 × u64) = supports up to 1024 resources
- prompts: 512 bits (8 × u64) = supports up to 512 prompts
Fields§
§version: u16Protocol version
tools: [u64; 128]Supported tools bitset (8192 bits = 1024 bytes)
resources: [u64; 16]Supported resources bitset (1024 bits = 128 bytes)
prompts: [u64; 8]Supported prompts bitset (512 bits = 64 bytes)
extensions: u64Extension flags
signature: [u8; 64]Ed25519 signature
Implementations§
Source§impl CapabilityManifest
impl CapabilityManifest
Sourcepub const MAX_RESOURCES: usize = 1024
pub const MAX_RESOURCES: usize = 1024
Maximum number of resources supported
Sourcepub const MAX_PROMPTS: usize = 512
pub const MAX_PROMPTS: usize = 512
Maximum number of prompts supported
Sourcepub fn new(version: u16) -> CapabilityManifest
pub fn new(version: u16) -> CapabilityManifest
Create a new empty capability manifest
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<&CapabilityManifest, DCPError>
pub fn from_bytes(bytes: &[u8]) -> Result<&CapabilityManifest, DCPError>
Parse manifest from bytes
Sourcepub fn signed_bytes(&self) -> &[u8] ⓘ
pub fn signed_bytes(&self) -> &[u8] ⓘ
Get the bytes that are signed (everything before the signature)
Sourcepub fn intersect(&self, other: &CapabilityManifest) -> CapabilityManifest
pub fn intersect(&self, other: &CapabilityManifest) -> CapabilityManifest
Compute capability intersection - single CPU instruction per word
Returns a new manifest containing only capabilities present in both manifests.
Sourcepub fn negotiate(
client: &CapabilityManifest,
server: &CapabilityManifest,
) -> CapabilityManifest
pub fn negotiate( client: &CapabilityManifest, server: &CapabilityManifest, ) -> CapabilityManifest
Negotiate a deny-by-default manifest from client and server offers.
Sourcepub fn require_tool(&self, tool_id: u16) -> Result<(), SecurityError>
pub fn require_tool(&self, tool_id: u16) -> Result<(), SecurityError>
Require that a negotiated tool capability is present.
Sourcepub fn require_resource(&self, resource_id: u16) -> Result<(), SecurityError>
pub fn require_resource(&self, resource_id: u16) -> Result<(), SecurityError>
Require that a negotiated resource capability is present.
Sourcepub fn require_prompt(&self, prompt_id: u16) -> Result<(), SecurityError>
pub fn require_prompt(&self, prompt_id: u16) -> Result<(), SecurityError>
Require that a negotiated prompt capability is present.
Sourcepub fn require_extension(&self, bit: u8) -> Result<(), SecurityError>
pub fn require_extension(&self, bit: u8) -> Result<(), SecurityError>
Require that a negotiated extension capability is present.
Sourcepub fn clear_tool(&mut self, tool_id: u16)
pub fn clear_tool(&mut self, tool_id: u16)
Clear a tool capability
Sourcepub fn set_resource(&mut self, resource_id: u16)
pub fn set_resource(&mut self, resource_id: u16)
Set a resource capability
Sourcepub fn clear_resource(&mut self, resource_id: u16)
pub fn clear_resource(&mut self, resource_id: u16)
Clear a resource capability
Sourcepub fn has_resource(&self, resource_id: u16) -> bool
pub fn has_resource(&self, resource_id: u16) -> bool
Check if a resource is supported
Sourcepub fn set_prompt(&mut self, prompt_id: u16)
pub fn set_prompt(&mut self, prompt_id: u16)
Set a prompt capability
Sourcepub fn clear_prompt(&mut self, prompt_id: u16)
pub fn clear_prompt(&mut self, prompt_id: u16)
Clear a prompt capability
Sourcepub fn has_prompt(&self, prompt_id: u16) -> bool
pub fn has_prompt(&self, prompt_id: u16) -> bool
Check if a prompt is supported
Sourcepub fn set_extension(&mut self, bit: u8)
pub fn set_extension(&mut self, bit: u8)
Set an extension flag
Sourcepub fn clear_extension(&mut self, bit: u8)
pub fn clear_extension(&mut self, bit: u8)
Clear an extension flag
Sourcepub fn has_extension(&self, bit: u8) -> bool
pub fn has_extension(&self, bit: u8) -> bool
Check if an extension is supported
Sourcepub fn tool_count(&self) -> u32
pub fn tool_count(&self) -> u32
Count the number of supported tools
Sourcepub fn resource_count(&self) -> u32
pub fn resource_count(&self) -> u32
Count the number of supported resources
Sourcepub fn prompt_count(&self) -> u32
pub fn prompt_count(&self) -> u32
Count the number of supported prompts
Sourcepub fn extension_count(&self) -> u32
pub fn extension_count(&self) -> u32
Count the number of enabled extensions
Sourcepub fn tool_ids(&self) -> impl Iterator<Item = u16>
pub fn tool_ids(&self) -> impl Iterator<Item = u16>
Get an iterator over all supported tool IDs
Sourcepub fn resource_ids(&self) -> impl Iterator<Item = u16>
pub fn resource_ids(&self) -> impl Iterator<Item = u16>
Get an iterator over all supported resource IDs
Sourcepub fn prompt_ids(&self) -> impl Iterator<Item = u16>
pub fn prompt_ids(&self) -> impl Iterator<Item = u16>
Get an iterator over all supported prompt IDs
Trait Implementations§
Source§impl Clone for CapabilityManifest
impl Clone for CapabilityManifest
Source§fn clone(&self) -> CapabilityManifest
fn clone(&self) -> CapabilityManifest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CapabilityManifest
impl Debug for CapabilityManifest
Source§impl Default for CapabilityManifest
impl Default for CapabilityManifest
Source§fn default() -> CapabilityManifest
fn default() -> CapabilityManifest
impl Eq for CapabilityManifest
Source§impl PartialEq for CapabilityManifest
impl PartialEq for CapabilityManifest
Source§fn eq(&self, other: &CapabilityManifest) -> bool
fn eq(&self, other: &CapabilityManifest) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for CapabilityManifest
Auto Trait Implementations§
impl Freeze for CapabilityManifest
impl RefUnwindSafe for CapabilityManifest
impl Send for CapabilityManifest
impl Sync for CapabilityManifest
impl Unpin for CapabilityManifest
impl UnsafeUnpin for CapabilityManifest
impl UnwindSafe for CapabilityManifest
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.