Skip to main content

Primitive

Enum Primitive 

Source
pub enum Primitive {
    Tool(Tool),
    Resource(Resource),
    ResourceTemplate(ResourceTemplate),
    Prompt(Prompt),
}
Expand description

Any primitive, tagged with its kind.

The four payloads stay separate types rather than collapsing into one struct with fourteen Option fields, because the fields that matter are not shared: Tool has an input schema and no uri, Resource has a uri and no input schema, and a single flat struct would let a resource be built with an input schema and no way to say whether that was a mistake.

Variants§

§

Tool(Tool)

A tool.

§

Resource(Resource)

A resource.

§

ResourceTemplate(ResourceTemplate)

A resource template.

§

Prompt(Prompt)

A prompt.

Implementations§

Source§

impl Primitive

Source

pub const fn kind(&self) -> PrimitiveKind

Which list this belongs to.

Source

pub const fn id(&self) -> &PrimitiveId

The key this primitive is filed under.

Source

pub fn meta(&self) -> PrimitiveMeta

The metadata a visibility decision is made from.

Derived from the payload rather than stored beside it, so the two cannot disagree — a separate meta field would be a second source of truth for a thing the payload already determines.

§What derives a requirement, and what does not

A requirement is raised when a session cannot correctly use the primitive without the feature. That is a narrower test than “the primitive has a field the revision does not define”, and the difference decides whether a feature is a gate or a filter.

A tool’s outputSchema is a gate. A tool that declares structured output answers with a structuredContent member, and a session that cannot represent it does not get a text fallback from the registry — it gets a result whose shape it will misread. This is the same StructuredContentToText decision the lowering path already made, and the registry has to agree with it or the two disagree about the same tool on the same session.

Annotations, icons, title and size are not gates. An older peer ignores a hint it does not recognise and the tool still works, which is the same reason Annotations does not raise required_features on a content block. Requiring a feature for decoration would hide a perfectly callable tool from every session on an older revision, and the hiding is silent — the peer simply never sees the tool.

Trait Implementations§

Source§

impl Clone for Primitive

Source§

fn clone(&self) -> Self

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 Debug for Primitive

Source§

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

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

impl From<Primitive> for Registered

Source§

fn from(primitive: Primitive) -> Self

Converts to this type from the input type.
Source§

impl From<Prompt> for Primitive

Source§

fn from(prompt: Prompt) -> Self

Converts to this type from the input type.
Source§

impl From<Resource> for Primitive

Source§

fn from(resource: Resource) -> Self

Converts to this type from the input type.
Source§

impl From<ResourceTemplate> for Primitive

Source§

fn from(template: ResourceTemplate) -> Self

Converts to this type from the input type.
Source§

impl From<Tool> for Primitive

Source§

fn from(tool: Tool) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Primitive

Source§

fn eq(&self, other: &Self) -> 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 Primitive

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more