//! Serde-based loose [NodeInfo] fetcher and parser. //! //! [NodeInfo]: https://github.com/jhass/nodeinfo/blob/main/PROTOCOL.md use serde::Deserialize; #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct NodeInfo1 { pub version: String, pub software: NodeInfo1Software, pub protocols: NodeInfo1Protocols, pub services: NodeInfo1Services, pub open_registrations: bool, pub usage: NodeInfo1Usage, pub metadata: serde_json::Value, } #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct NodeInfo2 { pub version: String, pub instance: Option, pub software: NodeInfo1Software, pub protocols: NodeInfo1Protocols, pub services: NodeInfo1Services, pub open_registrations: bool, pub usage: NodeInfo1Usage, pub metadata: serde_json::Value, } #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct NodeInfo1Software { pub name: String, pub version: String, pub repository: Option, pub homepage: Option, } #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct NodeInfo1Protocols { pub inbound: Vec, pub outbound: Vec, } #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct NodeInfo1Services { pub inbound: Vec, pub outbound: Vec, } #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct NodeInfo1Usage { pub users: NodeInfo1UsageUsers, pub local_posts: i32, pub local_comments: i32, } #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct NodeInfo1UsageUsers { pub total: i32, pub active_halfyear: i32, pub active_month: i32, } #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct NodeInfo2Instance { pub name: String, pub description: String, }