asonix
33c262461d
- Pull in primitives and traits that we need - Remove primitives that don't make sense - Limit the use of XsdAnyUri and similar primitives from public API - Add domain validation methods for ID and Actor fields - Add mutable borrows for Actor fields
32 lines
857 B
Rust
32 lines
857 B
Rust
use activitystreams_new::{
|
|
context,
|
|
object::{ApObject, Video},
|
|
prelude::*,
|
|
uri,
|
|
};
|
|
use chrono::Duration;
|
|
|
|
fn main() -> Result<(), anyhow::Error> {
|
|
let mut video = ApObject::new(Video::new());
|
|
|
|
video
|
|
.set_context(context())
|
|
.set_id(uri!("https://example.com/@example/lions"))
|
|
.set_media_type("video/webm".parse()?)
|
|
.set_url(uri!("https://example.com/@example/lions/video.webm"))
|
|
.set_summary("A cool video".to_owned())
|
|
.set_duration(Duration::minutes(4) + Duration::seconds(20))
|
|
.set_shares(uri!("https://example.com/@example/lions/video.webm#shares"));
|
|
|
|
println!("Video, {:#?}", video);
|
|
|
|
let s = serde_json::to_string(&video)?;
|
|
|
|
println!("json, {}", s);
|
|
|
|
let v: ApObject<Video> = serde_json::from_str(&s)?;
|
|
|
|
println!("Video again, {:#?}", v);
|
|
|
|
Ok(())
|
|
}
|