Compare commits

...

4 Commits

Author SHA1 Message Date
KD
d1f63a04e4 Merge branch 'enhance_song' into 'dev'
Added functions to song

See merge request kdeng00/icarus-models!33
2025-03-15 02:30:08 +00:00
KD
842fe6302e Added functions to song 2025-03-15 02:30:08 +00:00
KD
b9c0ba0549 Merge branch 'extend_ver_hash' into 'dev'
Extended the hash

See merge request kdeng00/icarus-models!31
2025-03-15 02:01:42 +00:00
bef3a376bd Extended the hash 2025-03-14 21:24:58 -04:00
2 changed files with 28 additions and 3 deletions

View File

@@ -47,7 +47,7 @@ extract_version:
script: script:
- apk add --no-cache jq - apk add --no-cache jq
- VERSION=$(grep 'version = "' Cargo.toml | awk -F'"' '{print $2}' | head -n 1) - VERSION=$(grep 'version = "' Cargo.toml | awk -F'"' '{print $2}' | head -n 1)
- VER_HASH=${CI_COMMIT_SHA:0:5} - VER_HASH=${CI_COMMIT_SHA:0:10}
- VERSION="$VERSION-$VER_HASH" - VERSION="$VERSION-$VER_HASH"
- if [ $? -ne 0 ]; then echo "Error extracting version"; exit 1; fi - if [ $? -ne 0 ]; then echo "Error extracting version"; exit 1; fi
- echo "Extracted version is" - echo "Extracted version is"

View File

@@ -90,9 +90,34 @@ impl Default for Song {
} }
impl Song { impl Song {
// TODO: Implement pub fn to_metadata_json(&self, pretty: bool) -> Result<String, serde_json::Error> {
pub fn to_metadata_json(&self) -> Result<String, serde_json::Error> { if pretty {
return serde_json::to_string_pretty(&self); return serde_json::to_string_pretty(&self);
} else {
return serde_json::to_string(&self);
}
}
// TODO: Implement
pub fn song_path(&self) -> String {
return String::new();
}
pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> {
let path = self.song_path();
let mut file = std::fs::File::open(path)?;
let mut buffer: Vec<u8> = Vec::new();
file.read_to_end(&mut buffer)?;
if buffer.len() == 0 {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
"File is empty",
))
} else {
Ok(buffer)
}
} }
} }