nostralink 0.2.1

Linked data library for nostr
Documentation
use crate::ldbuilder::jsonld_serde::JLDAttr;
use serde::{Deserialize, Serialize};
use serde_json::Value;

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SubscribeAction {
    #[serde(flatten)]
    pub ld: JLDAttr,

    #[serde(skip_serializing_if = "Option::is_none")]
    pub agent: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub object: Option<String>,
}

impl SubscribeAction {
    pub fn new() -> Self {
        Self {
            ld: JLDAttr::for_schema_type("SubscribeAction"),
            agent: None,
            object: None,
        }
    }

    pub fn value(&mut self) -> Result<Value, serde_json::Error> {
        serde_json::to_value(self)
    }
}