pub struct Data { /* private fields */ }
Expand description
A type containing some data and metadata for it.
This often, but not always, corresponds to data which could potentially have been a file in a file system. For example a image or a text document.
This type is mainly used when having auto generated content as content provided through a file should be loaded from a source and as such will be directly loaded and transfer encoded.
Clone
Data
is made to be cheap to clone and share.
For this it uses Arc
internally.
Implementations
sourceimpl Data
impl Data
sourcepub fn new(buffer: impl Into<Arc<[u8]>>, meta: impl Into<Arc<Metadata>>) -> Self
pub fn new(buffer: impl Into<Arc<[u8]>>, meta: impl Into<Arc<Metadata>>) -> Self
Create a new data instance.
pub fn plain_text(text: impl Into<String>, cid: ContentId) -> Data
sourcepub fn media_type(&self) -> &MediaType
pub fn media_type(&self) -> &MediaType
Access the content type.
sourcepub fn content_id(&self) -> &ContentId
pub fn content_id(&self) -> &ContentId
Access the content id.
sourcepub fn transfer_encode(&self, encoding_hint: TransferEncodingHint) -> EncData
pub fn transfer_encode(&self, encoding_hint: TransferEncodingHint) -> EncData
Transfer encode the given data.
This function will be called by the context implementation when loading and/or transfer encoding data. The context implementation might also not call it if it has a cached version of the transfer encoded data.
This functions expect a boundary pool and will remove all boundaries which do appear in the encoded representation of the data.