Merge pull request #85 from telebofr/input_file_constructors

Add `InputFile::{file,url,file_id}` constructors
This commit is contained in:
Temirkhan Myrzamadi 2019-11-26 20:29:49 +06:00 committed by GitHub
commit 6d83450a46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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<T>(file_id: T) -> Self
where
T: Into<String>
{
Self::FileId(file_id.into())
}
pub fn as_file(&self) -> Option<&PathBuf> {
match self {
Self::File(path) => Some(path),