pub struct Resource {
pub _id: u64,
pub tags: Vec<String>,
pub name: String,
pub description: Option<String>,
pub uri: Option<String>,
pub mime_type: Option<String>,
pub blob: Option<ByteBufB64>,
pub size: Option<u64>,
pub hash: Option<ByteArrayB64<32>>,
pub metadata: Option<Map<String, Value>>,
}Expand description
Represents a resource for AI Agents.
A Resource is a generic descriptor for any external piece of data an
agent may need to reference: an inline blob, a remote file, a URL, etc.
Every field except _id, tags and name is optional, so the same
type can describe both lightweight references (uri only) and fully
inlined assets (blob plus mime_type and hash).
The struct derives AndaDBSchema and FieldTyped, so it can be
embedded as a sub-document in any other Anda DB schema by simply using
Resource (or Option<Resource>) as a field type.
Fields§
§_id: u64The unique identifier for this resource in the Anda DB collection.
A list of tags that identifies the type of this resource. It is recommended to use the primary type of the file MIME type and the file extension as tags, for example: “text”, “image”, “audio”, “video”, “txt”, “md”, “png”, etc.
name: StringA human-readable name for this resource.
description: Option<String>A description of what this resource represents. This can be used by clients to improve the LLM’s understanding of available resources.
uri: Option<String>The URI of this resource.
mime_type: Option<String>MIME type, https://developer.mozilla.org/zh-CN/docs/Web/HTTP/MIME_types/Common_types
blob: Option<ByteBufB64>The binary data of this resource.
size: Option<u64>The size of the resource in bytes.
hash: Option<ByteArrayB64<32>>The SHA3-256 hash of the resource.
metadata: Option<Map<String, Value>>Metadata associated with this resource. This can include additional information such as creation date, author, etc.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Resource
impl<'de> Deserialize<'de> for Resource
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Resource, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Resource, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Resource
impl Serialize for Resource
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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 UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more