diff --git a/src/database/entry.rs b/src/database/entry.rs index 173bf79..e14ff3b 100644 --- a/src/database/entry.rs +++ b/src/database/entry.rs @@ -28,6 +28,7 @@ pub enum EntryValue { String(String), Number(f64), Address(Address), + Null, Invalid, } @@ -151,6 +152,7 @@ impl EntryValue { EntryValue::String(value) => ('S', value.to_owned()), EntryValue::Number(n) => ('N', n.to_string()), EntryValue::Address(address) => ('O', address.to_string()), + EntryValue::Null => ('X', "".to_string()), EntryValue::Invalid => return Err(anyhow!("Cannot serialize invalid value.")), }; @@ -163,10 +165,10 @@ impl std::str::FromStr for EntryValue { fn from_str(s: &str) -> Result { if s.len() < 2 { - if s.starts_with('S') { - Ok(EntryValue::String("".into())) - } else { - Ok(EntryValue::Invalid) + match s.chars().next() { + Some('S') => Ok(EntryValue::String("".into())), + Some('X') => Ok(EntryValue::Null), + _ => Ok(EntryValue::Invalid), } } else { let (type_char, content) = s.split_at(1); @@ -198,6 +200,7 @@ impl std::fmt::Display for EntryValue { EntryValue::Address(address) => ("ADDRESS", address.to_string()), EntryValue::String(string) => ("STRING", string.to_owned()), EntryValue::Number(n) => ("NUMBER", n.to_string()), + EntryValue::Null => ("NULL", "NULL".to_string()), EntryValue::Invalid => ("INVALID", "INVALID".to_string()), }; write!(f, "{}: {}", entry_type, entry_value) @@ -255,6 +258,11 @@ mod tests { let decoded = encoded.parse::()?; assert_eq!(entry, decoded); + let entry = EntryValue::Null; + let encoded = entry.to_string()?; + let decoded = encoded.parse::()?; + assert_eq!(entry, decoded); + Ok(()) } diff --git a/src/extractors/audio.rs b/src/extractors/audio.rs new file mode 100644 index 0000000..b6d7945 --- /dev/null +++ b/src/extractors/audio.rs @@ -0,0 +1,25 @@ +use super::Extractor; +use crate::{ + addressing::Address, + database::{entry::Entry, UpEndConnection}, + util::jobs::{Job, JobContainer, State}, +}; +use actix_web::web; +use anyhow::{anyhow, Result}; +use async_trait::async_trait; +use std::sync::{Arc, Mutex, RwLock}; +use webpage::{Webpage, WebpageOptions}; + +pub struct ID3Extractor; + +#[async_trait] +impl Extractor for ID3Extractor { + async fn get( + &self, + address: Address, + connection: Arc>, + job_container: Arc>, + ) -> Result> { + todo!(); + } +}