Skip to main content

IntoResourceContents

Trait IntoResourceContents 

Source
pub trait IntoResourceContents {
    // Required method
    fn into_contents(
        self,
        uri: &str,
        mime_type: Option<&str>,
    ) -> Result<Vec<ResourceContents>, ToolError>;
}
Expand description

Conversion of a resource handler’s return value into contents.

Return typeContents
String, &'static str, Cow<'static, str>Text
Vec<u8>Binary (base64 blob)
Json<T>JSON text (application/json unless another MIME type is set)
TextResourceContents, BlobResourceContents, ResourceContents, Vec<ResourceContents>As given
Result<T, E>T as above; E as for tools

The uri of generated contents is the requested URI, and their MIME type is the one declared on the resource.

Required Methods§

Source

fn into_contents( self, uri: &str, mime_type: Option<&str>, ) -> Result<Vec<ResourceContents>, ToolError>

Performs the conversion.

§Errors

Returns the handler’s error, or an internal error if serialization fails.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl IntoResourceContents for &'static str

Source§

fn into_contents( self, uri: &str, mime_type: Option<&str>, ) -> Result<Vec<ResourceContents>, ToolError>

Source§

impl IntoResourceContents for Cow<'static, str>

Source§

fn into_contents( self, uri: &str, mime_type: Option<&str>, ) -> Result<Vec<ResourceContents>, ToolError>

Source§

impl IntoResourceContents for String

Source§

fn into_contents( self, uri: &str, mime_type: Option<&str>, ) -> Result<Vec<ResourceContents>, ToolError>

Source§

impl IntoResourceContents for Vec<ResourceContents>

Source§

impl IntoResourceContents for Vec<u8>

Source§

fn into_contents( self, uri: &str, mime_type: Option<&str>, ) -> Result<Vec<ResourceContents>, ToolError>

Source§

impl<T: IntoResourceContents, E: IntoToolError> IntoResourceContents for Result<T, E>

Source§

fn into_contents( self, uri: &str, mime_type: Option<&str>, ) -> Result<Vec<ResourceContents>, ToolError>

Implementors§