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 type | Contents |
|---|---|
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§
Sourcefn into_contents(
self,
uri: &str,
mime_type: Option<&str>,
) -> Result<Vec<ResourceContents>, ToolError>
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".