Add InputFile::{file,url,file_id} constructors

This commit is contained in:
Waffle 2019-11-07 01:13:38 +03:00
parent 1df08f02c7
commit 08bf30296c

View file

@ -8,6 +8,24 @@ pub enum InputFile {
}
impl InputFile {
pub fn file(path: PathBuf) -> Self {
Self::File(path)
}
pub fn url<T>(url: T) -> Self
where
T: Into<String>
{
Self::Url(url.into())
}
pub fn file_id(file_id: T) -> Self
where
T: Into<String>
{
Self::FileId(fiel_id.into())
}
pub fn as_file(&self) -> Option<&PathBuf> {
match self {
Self::File(path) => Some(path),