forked from alemi/upub
feat: constructors for Node
This commit is contained in:
parent
9f06aa5993
commit
1cede82df6
1 changed files with 12 additions and 0 deletions
|
@ -85,6 +85,18 @@ impl<T : super::Base> Node<T> {
|
|||
}
|
||||
|
||||
impl Node<serde_json::Value>{
|
||||
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<impl super::Base>) -> 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()
|
||||
|
|
Loading…
Reference in a new issue