Added function to set value for metadata for known types #29
14
src/meta.rs
14
src/meta.rs
@@ -247,16 +247,16 @@ pub mod metadata {
|
||||
|
||||
pub fn parse_value(value: types::MetadataType) -> String {
|
||||
match value {
|
||||
types::MetadataType::String(val) => {
|
||||
val
|
||||
}
|
||||
types::MetadataType::Int(val) => {
|
||||
val.to_string()
|
||||
}
|
||||
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> {
|
||||
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)
|
||||
|
@@ -15,7 +15,7 @@ pub enum Type {
|
||||
#[derive(Debug)]
|
||||
pub enum MetadataType {
|
||||
String(String),
|
||||
Int(i32)
|
||||
Int(i32),
|
||||
}
|
||||
|
||||
impl MetadataType {
|
||||
@@ -32,9 +32,7 @@ impl MetadataType {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub mod access {
|
||||
|
||||
pub fn get_type(t: super::Type) -> Result<String, std::io::Error> {
|
||||
match t {
|
||||
super::Type::Title => Ok("TITLE".to_owned()),
|
||||
|
Reference in New Issue
Block a user