pub struct ResourceDescriptor {
pub id: ResourceId,
pub name: String,
pub description: Option<String>,
pub mime_type: Option<String>,
pub metadata: MetadataMap,
}Expand description
Describes a resource that a ResourceProvider can serve.
Resource descriptors are returned by
ResourceProvider::list_resources so that the host or model can
discover what data is available and request it by ResourceId.
Fields§
§id: ResourceIdUnique identifier used to request this resource.
name: StringA short, human-readable name for the resource.
description: Option<String>An optional longer description of the resource contents.
mime_type: Option<String>The MIME type of the resource data (e.g. "text/plain",
"application/json").
metadata: MetadataMapArbitrary key-value metadata attached to the descriptor.
Implementations§
Source§impl ResourceDescriptor
impl ResourceDescriptor
Sourcepub fn new(id: impl Into<ResourceId>, name: impl Into<String>) -> Self
pub fn new(id: impl Into<ResourceId>, name: impl Into<String>) -> Self
Builds a resource descriptor with no description or mime type.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Sets the description.
Sourcepub fn with_mime_type(self, mime_type: impl Into<String>) -> Self
pub fn with_mime_type(self, mime_type: impl Into<String>) -> Self
Sets the mime type.
Sourcepub fn with_metadata(self, metadata: MetadataMap) -> Self
pub fn with_metadata(self, metadata: MetadataMap) -> Self
Replaces the descriptor metadata.
Trait Implementations§
Source§impl Clone for ResourceDescriptor
impl Clone for ResourceDescriptor
Source§fn clone(&self) -> ResourceDescriptor
fn clone(&self) -> ResourceDescriptor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ResourceDescriptor
impl Debug for ResourceDescriptor
Source§impl<'de> Deserialize<'de> for ResourceDescriptor
impl<'de> Deserialize<'de> for ResourceDescriptor
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ResourceDescriptor
impl PartialEq for ResourceDescriptor
Source§impl Serialize for ResourceDescriptor
impl Serialize for ResourceDescriptor
impl Eq for ResourceDescriptor
impl StructuralPartialEq for ResourceDescriptor
Auto Trait Implementations§
impl Freeze for ResourceDescriptor
impl RefUnwindSafe for ResourceDescriptor
impl Send for ResourceDescriptor
impl Sync for ResourceDescriptor
impl Unpin for ResourceDescriptor
impl UnsafeUnpin for ResourceDescriptor
impl UnwindSafe for ResourceDescriptor
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
Mutably borrows from an owned value. Read more