// zotapi - Rust wrapper for Sot API as implemented by Hubzilla // Copyright (C) 2018 Harald Eilertsen // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . use crate::{error::Error}; use serde::Deserialize; use std::convert::TryFrom; #[derive(Debug, Default, Deserialize)] pub struct XChan { #[serde(alias = "xchan_hash")] pub hash: String, #[serde(alias = "xchan_guid")] pub guid: String, #[serde(alias = "xchan_guid_sig")] pub guid_sig: String, #[serde(alias = "xchan_pubkey")] pub pubkey: String, #[serde(alias = "xchan_photo_mimetype")] pub photo_mimetype: String, #[serde(alias = "xchan_photo_l")] pub photo_l: String, #[serde(alias = "xchan_photo_m")] pub photo_m: String, #[serde(alias = "xchan_photo_s")] pub photo_s: String, // For some reason the address field will be exported as `addr` // when part of an aboox entry, but `address` when just exporting // the xchan. `addr` is the name used in the database table. #[serde(alias = "xchan_addr")] pub address: String, #[serde(alias = "xchan_url")] pub url: String, #[serde(alias = "xchan_connurl")] pub connurl: String, #[serde(alias = "xchan_follow")] pub follow: String, #[serde(alias = "xchan_connpage")] pub connpage: String, #[serde(alias = "xchan_name")] pub name: String, #[serde(alias = "xchan_network")] pub network: String, #[serde(alias = "xchan_instance_url")] pub instance_url: String, #[serde(alias = "xchan_flags")] pub flags: u32, #[serde(alias = "xchan_photo_date")] pub photo_date: String, #[serde(alias = "xchan_name_date")] pub name_date: String, #[serde(alias = "xchan_hidden")] pub hidden: u32, #[serde(alias = "xchan_orphan")] pub orphan: u32, #[serde(alias = "xchan_censored")] pub censored: u32, #[serde(alias = "xchan_selfcensored")] pub selfcensored: u32, #[serde(alias = "xchan_system")] pub system: u32, #[serde(alias = "xchan_pubforum")] pub pubforum: u32, #[serde(alias = "deleted", default)] pub deleted: u32, } impl<'a> TryFrom<&'a str> for XChan { type Error = Error; fn try_from(s: &'a str) -> Result { Ok(serde_json::from_str(s)?) } }