2020-05-14 03:54:50 +00:00
|
|
|
use activitystreams_new::{
|
|
|
|
context,
|
|
|
|
object::{ApObject, Video},
|
2020-05-16 01:08:43 +00:00
|
|
|
prelude::*,
|
2020-05-14 03:54:50 +00:00
|
|
|
primitives::{XsdAnyUri, XsdString},
|
|
|
|
};
|
|
|
|
|
2020-05-16 01:08:43 +00:00
|
|
|
fn main() -> Result<(), anyhow::Error> {
|
2020-05-17 20:04:10 +00:00
|
|
|
let mut video = ApObject::new(Video::new());
|
2020-05-14 16:23:38 +00:00
|
|
|
|
2020-05-16 01:08:43 +00:00
|
|
|
video
|
|
|
|
.set_context(context())
|
|
|
|
.set_id("https://example.com/@example/lions".parse()?)
|
|
|
|
.set_media_type("video/webm".parse()?)
|
|
|
|
.set_url("https://example.com/@example/lions/video.webm".parse::<XsdAnyUri>()?)
|
|
|
|
.set_summary(XsdString::from("A cool video"))
|
|
|
|
.set_duration("PT4M20S".parse()?)
|
|
|
|
.set_shares("https://example.com/@example/lions/video.webm#shares".parse()?);
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 01:08:43 +00:00
|
|
|
println!("Video, {:#?}", video);
|
2020-05-14 03:54:50 +00:00
|
|
|
|
2020-05-16 01:08:43 +00:00
|
|
|
let s = serde_json::to_string(&video)?;
|
2020-05-14 03:54:50 +00:00
|
|
|
|
|
|
|
println!("json, {}", s);
|
|
|
|
|
|
|
|
let v: ApObject<Video> = serde_json::from_str(&s)?;
|
|
|
|
|
|
|
|
println!("Video again, {:#?}", v);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|