From 1cede82df6d35b5192178ea0d728917a64dc58d0 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 20 Mar 2024 07:54:24 +0100 Subject: [PATCH] feat: constructors for Node --- src/activitystream/node.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/activitystream/node.rs b/src/activitystream/node.rs index 4ebdffb0..f3e933ef 100644 --- a/src/activitystream/node.rs +++ b/src/activitystream/node.rs @@ -85,6 +85,18 @@ impl Node { } impl Node{ + pub fn link(uri: &str) -> Self { + Node::Link(Box::new(uri.to_string())) + } + + pub fn object(x: serde_json::Value) -> Self { + Node::Object(Box::new(x)) + } + + pub fn array(x: Vec) -> Self { + Node::Array(x.into_iter().map(|x| Node::object(x.underlying_json_object())).collect()) + } + pub async fn fetch(&mut self) -> reqwest::Result<()> { if let Node::Link(link) = self { *self = reqwest::Client::new()