pub struct Resource {
pub uri: String,
pub name: String,
pub description: Option<String>,
pub mime_type: String,
pub annotations: Option<Annotations>,
}
Expand description
Represents a resource in the extension with metadata
Fields§
§uri: String
URI representing the resource location (e.g., “file:///path/to/file” or “str:///content”)
name: String
Name of the resource
description: Option<String>
Optional description of the resource
mime_type: String
MIME type of the resource content (“text” or “blob”)
annotations: Option<Annotations>
Implementations§
Source§impl Resource
impl Resource
Sourcepub fn new<S: AsRef<str>>(
uri: S,
mime_type: Option<String>,
name: Option<String>,
) -> Result<Self>
pub fn new<S: AsRef<str>>( uri: S, mime_type: Option<String>, name: Option<String>, ) -> Result<Self>
Creates a new Resource from a URI with explicit mime type
Sourcepub fn with_uri<S: Into<String>>(
uri: S,
name: S,
priority: f32,
mime_type: Option<String>,
) -> Result<Self>
pub fn with_uri<S: Into<String>>( uri: S, name: S, priority: f32, mime_type: Option<String>, ) -> Result<Self>
Creates a new Resource with explicit URI, name, and priority
Sourcepub fn update_timestamp(&mut self)
pub fn update_timestamp(&mut self)
Updates the resource’s timestamp to the current time
Sourcepub fn with_priority(self, priority: f32) -> Self
pub fn with_priority(self, priority: f32) -> Self
Sets the priority of the resource and returns self for method chaining
Sourcepub fn mark_active(self) -> Self
pub fn mark_active(self) -> Self
Mark the resource as active, i.e. set its priority to 1.0
pub fn is_active(&self) -> bool
Sourcepub fn with_description<S: Into<String>>(self, description: S) -> Self
pub fn with_description<S: Into<String>>(self, description: S) -> Self
Sets the description of the resource
Sourcepub fn with_mime_type<S: Into<String>>(self, mime_type: S) -> Self
pub fn with_mime_type<S: Into<String>>(self, mime_type: S) -> Self
Sets the MIME type of the resource
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Resource
impl<'de> Deserialize<'de> for Resource
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
impl StructuralPartialEq for Resource
Auto Trait Implementations§
impl Freeze for Resource
impl RefUnwindSafe for Resource
impl Send for Resource
impl Sync for Resource
impl Unpin for Resource
impl UnwindSafe for Resource
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