20 lines
432 B
Rust
20 lines
432 B
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::errors::{Error, ErrorStatus};
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
pub struct Site {
|
|
pub url: String,
|
|
pub name: Option<String>,
|
|
}
|
|
|
|
pub fn load_names(names: String) -> Result<Vec<Site>, Error> {
|
|
match serde_json::from_str::<Vec<Site>>(&names) {
|
|
Ok(content) => Ok(content),
|
|
Err(err) => Err(Error {
|
|
status: ErrorStatus::ParsingError,
|
|
data: err.to_string(),
|
|
}),
|
|
}
|
|
}
|