30 lines
806 B
Rust
30 lines
806 B
Rust
use activitystreams_new::{
|
|
context,
|
|
object::{ApObject, Video},
|
|
primitives::{XsdAnyUri, XsdString},
|
|
};
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
let video = Video::builder()
|
|
.context(context())
|
|
.id("https://example.com/@example/lions".parse::<XsdAnyUri>()?)
|
|
.url("https://example.com/@example/lions/video.webm".parse::<XsdAnyUri>()?)
|
|
.summary(XsdString::from("A cool video"))
|
|
.media_type("video/webm".parse()?)
|
|
.duration("PT4M20S".parse()?)
|
|
.build();
|
|
|
|
let v = ApObject::builder().inner(video).build();
|
|
|
|
println!("Video, {:#?}", v);
|
|
|
|
let s = serde_json::to_string(&v)?;
|
|
|
|
println!("json, {}", s);
|
|
|
|
let v: ApObject<Video> = serde_json::from_str(&s)?;
|
|
|
|
println!("Video again, {:#?}", v);
|
|
|
|
Ok(())
|
|
}
|