1
0
mirror of https://github.com/pcvolkmer/osc-variant.git synced 2025-12-16 07:33:20 +00:00

feat: add shortcut methods to read OSC and Profile files

This commit is contained in:
2023-12-31 18:34:42 +01:00
parent dc62454a74
commit 221b2c6a2f
2 changed files with 22 additions and 6 deletions

View File

@@ -25,6 +25,7 @@
use std::error::Error;
use std::fmt::{Debug, Display, Formatter};
use std::fs;
use std::marker::PhantomData;
use std::path::Path;
use std::str::FromStr;
@@ -206,3 +207,20 @@ impl TryFrom<InputFile> for Profile {
};
}
}
/// Shortcut methods for OSC and Profile files
pub struct FileReader<FileType> {
file_type: PhantomData<FileType>,
}
impl FileReader<OnkostarEditor> {
pub fn read(filename: String) -> Result<OnkostarEditor, FileError> {
TryInto::<OnkostarEditor>::try_into(InputFile::read(filename.to_string(), None)?)
}
}
impl FileReader<Profile> {
pub fn read(filename: String) -> Result<Profile, FileError> {
TryInto::<Profile>::try_into(InputFile::read(filename.to_string(), None)?)
}
}