fix: cloudlink score creation wasn't working

This commit is contained in:
Adamaq01 2023-07-16 08:15:16 +02:00
parent 832fc3e344
commit b06551e338
2 changed files with 10 additions and 4 deletions

View File

@ -76,7 +76,7 @@ pub fn process_pbs(user: &str, music: &Node, encoding: EncodingType) -> Result<V
song_id,
difficulty,
};
let score = Score::from_property(value.as_slice().try_into()?);
let score = Score::from_slice(value)?;
scores.insert(chart, score);
}
}

View File

@ -1,3 +1,5 @@
use anyhow::Result;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
pub struct Chart {
pub song_id: u32,
@ -19,10 +21,14 @@ impl Score {
ret
}
pub fn from_property(property: &[u32; 21]) -> Self {
Self {
property: *property,
pub fn from_slice(vec: &[u32]) -> Result<Self> {
if vec.len() < 21 {
return Err(anyhow::anyhow!("Could not parse score"));
}
let mut ret = Self::default();
ret.property.copy_from_slice(&vec[..21]);
Ok(ret)
}
pub fn cloud_score_mut(&mut self) -> &mut u32 {