#[non_exhaustive]pub enum FileData {
Bytes {
data: Bytes,
},
Url {
url: Url,
},
Reference {
reference: BTreeMap<String, String>,
},
Text {
text: String,
},
}Expand description
The payload of a file: inline bytes, a URL, a provider reference or an inline text document.
Wire format is tagged by type: {"type": "data", "data": "<base64>"},
{"type": "url", "url": "..."}, {"type": "reference", "reference": {..}}
or {"type": "text", "text": "..."}. Generated files (results, stream
parts) only use the data and url forms.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Bytes
Inline bytes, serialized as standard base64 with padding.
Url
A URL the provider fetches itself.
Reference
A file previously uploaded to one or more providers.
Text
An inline text document.
Implementations§
Source§impl FileData
impl FileData
Sourcepub fn from_base64(text: &str) -> Result<FileData, DecodeError>
pub fn from_base64(text: &str) -> Result<FileData, DecodeError>
Inline bytes from a base64 string (standard alphabet, padding optional).
§Errors
Returns the decoding error when text is not valid base64.
Sourcepub fn reference(provider: impl Into<String>, id: impl Into<String>) -> FileData
pub fn reference(provider: impl Into<String>, id: impl Into<String>) -> FileData
A reference to a file uploaded to a single provider.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FileData
impl<'de> Deserialize<'de> for FileData
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileData, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileData, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for FileData
Source§impl From<FileData> for FileSource
impl From<FileData> for FileSource
Source§impl Serialize for FileData
impl Serialize for FileData
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 FileData
Source§impl TryFrom<FileSource> for FileData
impl TryFrom<FileSource> for FileData
Source§fn try_from(source: FileSource) -> Result<Self, Self::Error>
fn try_from(source: FileSource) -> Result<Self, Self::Error>
Converts without I/O: base64 is decoded, URLs (including data:) are
passed through, and paths are rejected with
FileSourceError::UnreadPath.
Source§type Error = FileSourceError
type Error = FileSourceError
Auto Trait Implementations§
impl !Freeze for FileData
impl RefUnwindSafe for FileData
impl Send for FileData
impl Sync for FileData
impl Unpin for FileData
impl UnsafeUnpin for FileData
impl UnwindSafe for FileData
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.