#[non_exhaustive]pub struct EndpointSchema {
pub name: String,
pub code: u32,
pub parameters: Vec<Field>,
pub returns: Vec<Field>,
pub stream_response: Option<Type>,
pub description: String,
pub json_schema: Value,
pub roles: Vec<String>,
pub errors: Vec<EndpointErrorSchema>,
pub meta: MetaMap,
}Expand description
EndpointSchema is a struct that represents a single endpoint in the API.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringThe name of the endpoint (e.g. UserListSymbols)
code: u32The method code of the endpoint (e.g. 10020)
parameters: Vec<Field>A list of parameters that the endpoint accepts (e.g. “symbol” of type String)
returns: Vec<Field>A list of fields that the endpoint returns
stream_response: Option<Type>The type of the stream response (if any)
description: StringA description of the endpoint added by with_description method
json_schema: ValueThe JSON schema of the endpoint (Default::default())
roles: Vec<String>§errors: Vec<EndpointErrorSchema>Public error variants that handlers may return for this endpoint.
meta: MetaMapEmitter annotations — see MetaMap. Empty in 2.0;
consumed by the OpenAPI/AsyncAPI emitters in 2.1.
Implementations§
Source§impl EndpointSchema
impl EndpointSchema
Sourcepub fn new(
name: impl Into<String>,
code: u32,
parameters: Vec<Field>,
returns: Vec<Field>,
) -> EndpointSchema
pub fn new( name: impl Into<String>, code: u32, parameters: Vec<Field>, returns: Vec<Field>, ) -> EndpointSchema
Creates a new EndpointSchema with the given name, method code, parameters and returns.
Sourcepub fn with_meta(self, meta: MetaMap) -> EndpointSchema
pub fn with_meta(self, meta: MetaMap) -> EndpointSchema
Attach emitter annotations. See MetaMap.
Sourcepub fn with_stream_response_type(self, stream_response: Type) -> EndpointSchema
pub fn with_stream_response_type(self, stream_response: Type) -> EndpointSchema
Adds a stream response type field to the endpoint.
Sourcepub fn with_description(self, desc: impl Into<String>) -> EndpointSchema
pub fn with_description(self, desc: impl Into<String>) -> EndpointSchema
Adds a description field to the endpoint.
Sourcepub fn with_roles(self, roles: Vec<String>) -> EndpointSchema
pub fn with_roles(self, roles: Vec<String>) -> EndpointSchema
Adds allowed roles to the endpoint.
Sourcepub fn with_errors(self, errors: Vec<EndpointErrorSchema>) -> EndpointSchema
pub fn with_errors(self, errors: Vec<EndpointErrorSchema>) -> EndpointSchema
Adds public error variants to the endpoint.
Source§impl EndpointSchema
impl EndpointSchema
Sourcepub fn tool_name(&self) -> String
pub fn tool_name(&self) -> String
MCP tool name for this endpoint: the endpoint name in snake_case
(e.g. UserListSymbols → user_list_symbols).
Sourcepub fn to_mcp_input_schema(
&self,
registry: &TypeRegistry,
) -> Result<Value, Report>
pub fn to_mcp_input_schema( &self, registry: &TypeRegistry, ) -> Result<Value, Report>
MCP inputSchema: an object schema over parameters. Non-Optional
parameters are listed in required.
Sourcepub fn to_mcp_output_schema(
&self,
registry: &TypeRegistry,
) -> Result<Value, Report>
pub fn to_mcp_output_schema( &self, registry: &TypeRegistry, ) -> Result<Value, Report>
MCP outputSchema: an object schema over returns.
Trait Implementations§
Source§impl Clone for EndpointSchema
impl Clone for EndpointSchema
Source§fn clone(&self) -> EndpointSchema
fn clone(&self) -> EndpointSchema
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 EndpointSchema
impl Debug for EndpointSchema
Source§impl Default for EndpointSchema
impl Default for EndpointSchema
Source§fn default() -> EndpointSchema
fn default() -> EndpointSchema
Source§impl<'de> Deserialize<'de> for EndpointSchema
impl<'de> Deserialize<'de> for EndpointSchema
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<EndpointSchema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<EndpointSchema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for EndpointSchema
impl Serialize for EndpointSchema
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for EndpointSchema
impl RefUnwindSafe for EndpointSchema
impl Send for EndpointSchema
impl Sync for EndpointSchema
impl Unpin for EndpointSchema
impl UnsafeUnpin for EndpointSchema
impl UnwindSafe for EndpointSchema
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 more