Added function to set value for metadata for known types #29
17
src/meta.rs
17
src/meta.rs
@@ -244,6 +244,23 @@ pub mod metadata {
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_value(value: types::MetadataType) -> String {
|
||||
match value {
|
||||
types::MetadataType::String(val) => {
|
||||
val
|
||||
}
|
||||
types::MetadataType::Int(val) => {
|
||||
val.to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_meta_value(t: types::Type, filepath: &String, value: types::MetadataType) -> Result<String, std::io::Error> {
|
||||
let parsed_val = parse_value(value);
|
||||
|
||||
set_meta(t, filepath, &parsed_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
21
src/types.rs
21
src/types.rs
@@ -12,6 +12,27 @@ pub enum Type {
|
||||
DiscCount,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum MetadataType {
|
||||
String(String),
|
||||
Int(i32)
|
||||
}
|
||||
|
||||
impl MetadataType {
|
||||
pub fn from_str(s: &str) -> Self {
|
||||
MetadataType::String(s.to_string())
|
||||
}
|
||||
|
||||
pub fn from_string(s: String) -> Self {
|
||||
MetadataType::String(s)
|
||||
}
|
||||
|
||||
pub fn from_int(i: i32) -> Self {
|
||||
MetadataType::Int(i)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub mod access {
|
||||
|
||||
pub fn get_type(t: super::Type) -> Result<String, std::io::Error> {
|
||||
|
Reference in New Issue
Block a user