Add `InputFile::as{file,file_id,url}` methods
+use std::path::PathBuf;
+
#[derive(Debug, Hash, PartialEq, Eq, Clone)]
pub enum InputFile {
- File(std::path::PathBuf),
+ File(PathBuf),
Url(String),
FileId(String),
}
+impl InputFile {
+ pub fn as_file(&self) -> Option<&PathBuf> {
+ match self {
+ Self::File(path) => Some(path),
+ _ => None,
+ }
+ }
+
+ pub fn as_url(&self) -> Option<&String> {
+ match self {
+ Self::Url(url) => Some(url),
+ _ => None,
+ }
+ }
+
+ pub fn as_file_id(&self) -> Option<&String> {
+ match self {
+ Self::FileId(id) => Some(id),
+ _ => None,
+ }
+ }
+}
+
impl serde::Serialize for InputFile {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
