2024-05-13 21:31:33 +02:00
|
|
|
use super::objects::SortAlphabetically;
|
|
|
|
|
|
|
|
|
|
pub async fn deserialize_user(data: String) -> anyhow::Result<super::objects::User> {
|
|
|
|
|
let user: super::objects::User = serde_json::from_str(&data)?;
|
|
|
|
|
Ok(user)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn serialize_user(user: super::objects::User) -> anyhow::Result<String> {
|
|
|
|
|
let data = serde_json::to_string(&SortAlphabetically(&user))?;
|
|
|
|
|
Ok(data)
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-19 22:15:19 +01:00
|
|
|
pub async fn deserialize_versia_type(data: String) -> anyhow::Result<String> {
|
|
|
|
|
let versia_type: String = serde_json::from_str(&data)?;
|
2024-08-28 15:24:22 +02:00
|
|
|
Ok(versia_type)
|
2024-05-13 21:31:33 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-28 15:24:22 +02:00
|
|
|
pub async fn serialize_versia_type(
|
2024-11-19 22:15:19 +01:00
|
|
|
versia_type: String,
|
2024-05-13 21:31:33 +02:00
|
|
|
) -> anyhow::Result<String> {
|
2024-08-28 15:24:22 +02:00
|
|
|
let data = serde_json::to_string(&versia_type)?;
|
2024-05-13 21:31:33 +02:00
|
|
|
Ok(data)
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-18 03:56:25 +02:00
|
|
|
pub async fn deserialize_note(data: String) -> anyhow::Result<super::objects::Note> {
|
|
|
|
|
let post: super::objects::Note = serde_json::from_str(&data)?;
|
|
|
|
|
Ok(post)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn serialize_note(post: super::objects::Note) -> anyhow::Result<String> {
|
|
|
|
|
let data = serde_json::to_string(&SortAlphabetically(&post))?;
|
|
|
|
|
Ok(data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn deserialize_outbox(data: String) -> anyhow::Result<super::objects::Outbox> {
|
|
|
|
|
let outbox: super::objects::Outbox = serde_json::from_str(&data)?;
|
|
|
|
|
Ok(outbox)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn serialize_outbox(outbox: super::objects::Outbox) -> anyhow::Result<String> {
|
|
|
|
|
let data = serde_json::to_string(&SortAlphabetically(&outbox))?;
|
|
|
|
|
Ok(data)
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-13 21:31:33 +02:00
|
|
|
#[inline]
|
|
|
|
|
pub fn request_client() -> reqwest::Client {
|
|
|
|
|
reqwest::Client::builder()
|
|
|
|
|
.user_agent(concat!(
|
|
|
|
|
env!("CARGO_PKG_NAME"),
|
|
|
|
|
"/",
|
|
|
|
|
env!("CARGO_PKG_VERSION"),
|
|
|
|
|
))
|
|
|
|
|
.build()
|
|
|
|
|
.unwrap()
|
|
|
|
|
}
|