Added function to set value for metadata for known types #29

Merged
phoenix merged 4 commits from set_meta_value into devel 2025-06-21 20:40:16 +00:00
2 changed files with 8 additions and 10 deletions
Showing only changes of commit 2bd532e0dd - Show all commits

View File

@@ -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)

View File

@@ -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()),