#[non_exhaustive]pub enum FileSource {
Bytes {
data: Bytes,
},
Base64 {
data: String,
},
Url {
url: Url,
},
Reference {
reference: ProviderReference,
},
Text {
text: String,
},
Path {
path: PathBuf,
},
}Expand description
Where the bytes of a file part come from.
Compared with the provider-level FileData, applications may also pass
base64 text (decoded during conversion) and a local path (read during
conversion). Wire format is tagged by type: data (base64 bytes),
base64, url, reference, text, path.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Bytes
Inline bytes.
Base64
Base64 text, decoded during conversion.
Url
A URL, including data: URLs.
Reference
A file previously uploaded to one or more providers.
Fields
reference: ProviderReferenceProvider key → provider-specific file id.
Text
An inline text document.
Path
A local file read during conversion.
Implementations§
Source§impl FileSource
impl FileSource
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 single-provider reference.
Sourcepub fn parse_url(url: &str) -> Result<Self, ParseError>
pub fn parse_url(url: &str) -> Result<Self, ParseError>
Parses a URL string into a URL source.
§Errors
Returns the parse error when url is not an absolute URL.
Sourcepub fn as_bytes(&self) -> Option<&Bytes>
pub fn as_bytes(&self) -> Option<&Bytes>
Returns the inline bytes when this is a FileSource::Bytes.
Sourcepub fn as_url(&self) -> Option<&Url>
pub fn as_url(&self) -> Option<&Url>
Returns the URL when this is a FileSource::Url.
Sourcepub fn as_reference(&self) -> Option<&ProviderReference>
pub fn as_reference(&self) -> Option<&ProviderReference>
Returns the provider reference when this is a FileSource::Reference.
Sourcepub fn is_data_url(&self) -> bool
pub fn is_data_url(&self) -> bool
Returns true for a data: URL.
Sourcepub fn data_url(&self) -> Option<Result<DataUrl, InvalidDataContentError>>
pub fn data_url(&self) -> Option<Result<DataUrl, InvalidDataContentError>>
Parses the data: URL when this is one.
§Errors
Returns InvalidDataContentError when the data URL is malformed.
Sourcepub fn decoded_bytes(&self) -> Result<Option<Bytes>, InvalidDataContentError>
pub fn decoded_bytes(&self) -> Result<Option<Bytes>, InvalidDataContentError>
Decodes inline content (Bytes or Base64) into bytes.
Returns None for sources that are not inline binary content.
§Errors
Returns InvalidDataContentError when base64 text does not decode.
Trait Implementations§
Source§impl Clone for FileSource
impl Clone for FileSource
Source§fn clone(&self) -> FileSource
fn clone(&self) -> FileSource
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileSource
impl Debug for FileSource
Source§impl<'de> Deserialize<'de> for FileSource
impl<'de> Deserialize<'de> for FileSource
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 FileSource
Source§impl From<BTreeMap<String, String>> for FileSource
impl From<BTreeMap<String, String>> for FileSource
Source§fn from(reference: ProviderReference) -> Self
fn from(reference: ProviderReference) -> Self
Source§impl From<Bytes> for FileSource
impl From<Bytes> for FileSource
Source§impl From<FileData> for FileSource
impl From<FileData> for FileSource
Source§impl From<PathBuf> for FileSource
impl From<PathBuf> for FileSource
Source§impl From<Url> for FileSource
impl From<Url> for FileSource
Source§impl PartialEq for FileSource
impl PartialEq for FileSource
Source§impl Serialize for FileSource
impl Serialize for FileSource
impl StructuralPartialEq for FileSource
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 FileSource
impl RefUnwindSafe for FileSource
impl Send for FileSource
impl Sync for FileSource
impl Unpin for FileSource
impl UnsafeUnpin for FileSource
impl UnwindSafe for FileSource
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.