Skip to main content

RustResource

Trait RustResource 

Source
pub trait RustResource: Send + Sync {
    type Params: DeserializeOwned + Send;

    const URI_TEMPLATE: &'static str;
    const NAME: &'static str;
    const DESCRIPTION: &'static str;
    const MIME_TYPE: Option<&'static str>;

    // Required method
    fn read(
        &self,
        uri: &str,
        params: Self::Params,
    ) -> impl Future<Output = Result<ResourceOutput, ToolError>> + Send;

    // Provided method
    fn description(&self) -> Cow<'static, str> { ... }
}
Expand description

A custom resource or resource template implemented in Rust.

Required Associated Constants§

Source

const URI_TEMPLATE: &'static str

URI template pattern (e.g. "file:///logs/{date}/{app}.log" or "config://app").

Source

const NAME: &'static str

Unique resource name.

Source

const DESCRIPTION: &'static str

Human-readable description.

Source

const MIME_TYPE: Option<&'static str>

Optional MIME type.

Required Associated Types§

Source

type Params: DeserializeOwned + Send

Strongly-typed parameters extracted from URI variables.

Required Methods§

Source

fn read( &self, uri: &str, params: Self::Params, ) -> impl Future<Output = Result<ResourceOutput, ToolError>> + Send

Read the resource with URI and extracted parameters.

Provided Methods§

Source

fn description(&self) -> Cow<'static, str>

Return the resource description.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§