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:
@@ -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)?)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user