explicit NULL entryvalue
This commit is contained in:
parent
e3be9578bd
commit
dc808aab22
2 changed files with 37 additions and 4 deletions
|
@ -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<Self, Self::Err> {
|
||||
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::<EntryValue>()?;
|
||||
assert_eq!(entry, decoded);
|
||||
|
||||
let entry = EntryValue::Null;
|
||||
let encoded = entry.to_string()?;
|
||||
let decoded = encoded.parse::<EntryValue>()?;
|
||||
assert_eq!(entry, decoded);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
25
src/extractors/audio.rs
Normal file
25
src/extractors/audio.rs
Normal file
|
@ -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<Mutex<UpEndConnection>>,
|
||||
job_container: Arc<RwLock<JobContainer>>,
|
||||
) -> Result<Vec<Entry>> {
|
||||
todo!();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue