#[non_exhaustive]pub enum FileData {
Bytes {
data: Bytes,
},
Url {
url: Url,
},
Reference {
reference: ProviderReference,
},
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.
Fields
reference: ProviderReferenceProvider key → provider-specific file id.
Text
An inline text document.
Implementations§
Source§impl FileData
impl FileData
Sourcepub fn from_base64(text: &str) -> Result<Self, DecodeError>
pub fn from_base64(text: &str) -> Result<Self, 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>) -> Self
pub fn reference(provider: impl Into<String>, id: impl Into<String>) -> Self
A reference to a file uploaded to a single provider.
Sourcepub fn as_reference(&self) -> Option<&ProviderReference>
pub fn as_reference(&self) -> Option<&ProviderReference>
Returns the provider reference when this is a reference payload.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FileData
impl<'de> Deserialize<'de> for FileData
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>,
impl Eq for FileData
Source§impl From<BTreeMap<String, String>> for FileData
impl From<BTreeMap<String, String>> for FileData
Source§fn from(reference: ProviderReference) -> Self
fn from(reference: ProviderReference) -> Self
impl StructuralPartialEq for FileData
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.