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-06-03 20:35:45 +00:00
|
|
|
uri,
|
2020-05-14 03:54:50 +00:00
|
|
|
};
|
|
|
|
|
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())
|
2020-06-03 20:35:45 +00:00
|
|
|
.set_id(uri!("https://example.com/@example/lions"))
|
2020-05-16 01:08:43 +00:00
|
|
|
.set_media_type("video/webm".parse()?)
|
2020-06-03 20:35:45 +00:00
|
|
|
.set_url(uri!("https://example.com/@example/lions/video.webm"))
|
2020-06-03 17:31:54 +00:00
|
|
|
.set_summary("A cool video".to_owned())
|
2020-05-16 01:08:43 +00:00
|
|
|
.set_duration("PT4M20S".parse()?)
|
2020-06-03 20:35:45 +00:00
|
|
|
.set_shares(uri!("https://example.com/@example/lions/video.webm#shares"));
|
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(())
|
|
|
|
}
|