Fix example, docs for activitystreams-ext

This commit is contained in:
asonix 2020-07-26 12:16:23 -05:00
parent 394bf499f9
commit 7dad81d2f3
6 changed files with 39 additions and 21 deletions

16
CHANGELOG.md Normal file
View file

@ -0,0 +1,16 @@
# Unreleased
# 0.7.0-alpha.3
- Add `.into_parts()` for some types where it makes sense
- All activity subtypes
- ApActor
- ApObject
# 0.7.0-alpha.2
- Add `.iter()`, `.iter_mut()` and `.into_iter()` for `OneOrMany<T>`
# 0.7.0-alpha.1
- The `items` methods for collections now deal in options
# 0.7.0-alpha.0
- Complete rewrite from 0.6.x, [check the docs](https://docs.rs/activitystreams)

View file

@ -0,0 +1,10 @@
# Unreleased
# 0.1.0-alpha.2
Fix docs
# 0.1.0-alpha.1
Add `.into_parts()` for ext types
# 0.1.0-alpha.0
Initial release

View file

@ -1,7 +1,7 @@
[package]
name = "activitystreams-ext"
description = "Extension types for the ActivityStreams crate"
version = "0.1.0-alpha.1"
version = "0.1.0-alpha.2"
license = "GPL-3.0"
authors = ["asonix <asonix@asonix.dog>"]
repository = "https://git.asonix.dog/Aardwolf/activitystreams"

View file

@ -12,7 +12,7 @@ First, add ActivityStreams to your dependencies
```toml
[dependencies]
activitystreams = "0.7.0-alpha.3"
activitystreams-ext = "0.1.0-alpha.1"
activitystreams-ext = "0.1.0-alpha.2"
```
For an example, we'll implement a PublicKey extension and demonstrate usage with Ext1

View file

@ -1,12 +1,12 @@
use activitystreams_ext::{Ext1, UnparsedExtension};
use activitystreams::{
actor::{ApActor, Person},
context,
prelude::*,
primitives::XsdAnyUri,
security,
unparsed::UnparsedMutExt,
url::Url,
};
use activitystreams_ext::{Ext1, UnparsedExtension};
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[serde(rename_all = "camelCase")]
@ -17,8 +17,8 @@ pub struct PublicKey {
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PublicKeyInner {
id: XsdAnyUri,
owner: XsdAnyUri,
id: Url,
owner: Url,
public_key_pem: String,
}
@ -43,11 +43,7 @@ where
pub type ExtendedPerson = Ext1<ApActor<Person>, PublicKey>;
fn main() -> Result<(), anyhow::Error> {
let actor = ApActor::new(
"http://in.box".parse()?,
"http://out.box".parse()?,
Person::new(),
);
let actor = ApActor::new("http://in.box".parse()?, Person::new());
let mut person = Ext1::new(
actor,

View file

@ -12,20 +12,20 @@
//! ```toml
//! [dependencies]
//! activitystreams = "0.7.0-alpha.3"
//! activitystreams-ext = "0.1.0-alpha.1"
//! activitystreams-ext = "0.1.0-alpha.2"
//! ```
//!
//! For an example, we'll implement a PublicKey extension and demonstrate usage with Ext1
//! ```rust
//! use activitystreams_ext::{Ext1, UnparsedExtension};
//! use activitystreams::{
//! actor::{ApActor, Person},
//! context,
//! prelude::*,
//! primitives::XsdAnyUri,
//! security,
//! unparsed::UnparsedMutExt,
//! url::Url,
//! };
//! use activitystreams_ext::{Ext1, UnparsedExtension};
//!
//! #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
//! #[serde(rename_all = "camelCase")]
@ -36,8 +36,8 @@
//! #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
//! #[serde(rename_all = "camelCase")]
//! pub struct PublicKeyInner {
//! id: XsdAnyUri,
//! owner: XsdAnyUri,
//! id: Url,
//! owner: Url,
//! public_key_pem: String,
//! }
//!
@ -62,11 +62,7 @@
//! pub type ExtendedPerson = Ext1<ApActor<Person>, PublicKey>;
//!
//! fn main() -> Result<(), anyhow::Error> {
//! let actor = ApActor::new(
//! "http://in.box".parse()?,
//! "http://out.box".parse()?,
//! Person::new(),
//! );
//! let actor = ApActor::new("http://in.box".parse()?, Person::new());
//!
//! let mut person = Ext1::new(
//! actor,