Skip to content

Commit 62dee52

Browse files
authored
Merge pull request #2 from dscottboggs/fix/examples
Pre-release tasks - chang the name of the project from elefren to mastodon-async - fix and updates some documentation - fix the examples
2 parents 6fb6380 + ca7777c commit 62dee52

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+494
-3889
lines changed

.cargo-ok

-1
This file was deleted.

.clog.toml

-3
This file was deleted.

.travis.yml

-42
This file was deleted.

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
<a name="v1.0.0"></a>
2+
## v1.0.0
3+
4+
#### Breaking Changes
5+
6+
* All functions which interact with the API are now async. As a part of this
7+
change, the streaming API now returns a `Stream` instead of an `Iterator`.
8+
* The crate has been renamed to `mastodon-async`.
9+
* Search API v1 has been removed.
10+
11+
#### Features
12+
* Structured logging
13+
14+
#### Bug fixes
15+
* Streaming API was incomplete, it now works
16+
117
<a name="v0.18.0"></a>
218
## v0.18.0 (2019-01-05)
319

Cargo.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "elefren"
2+
name = "mastodon-async"
33
version = "1.0.0"
44
authors = ["Aaron Power <[email protected]>", "Paul Woolcock <[email protected]>", "D. Scott Boggs <[email protected]>"]
55
description = "A wrapper around the Mastodon API."
@@ -8,7 +8,7 @@ keywords = ["api", "web", "social", "mastodon", "wrapper"]
88
categories = ["web-programming", "web-programming::http-client", "api-bindings"]
99
license = "MIT/Apache-2.0"
1010
edition = "2021"
11-
repository = "https://github.com/dscottboggs/elefren.git"
11+
repository = "https://github.com/dscottboggs/mastodon-async.git"
1212

1313
[package.metadata.docs.rs]
1414
features = ["all"]
@@ -70,9 +70,11 @@ features = ["io"]
7070
tokio-test = "0.4.2"
7171
futures-util = "0.3.25"
7272
indoc = "1.0"
73-
pretty_env_logger = "0.3.0"
7473
skeptic = "0.13"
7574
tempfile = "3"
75+
# for examples:
76+
femme = "2.2.1"
77+
html2text = "0.4.4"
7678

7779
[build-dependencies.skeptic]
7880
version = "0.13"

LICENCE-APACHE

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Copyright 2016 Aaron Power
2+
Copyright © 2022 D. Scott Boggs
23

34
Licensed under the Apache License, Version 2.0 (the "License");
45
you may not use this file except in compliance with the License.

LICENCE-MIT

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License (MIT)
22

33
Copyright (c) 2016 Aaron Power
4+
Copyright © 2022 D. Scott Boggs
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

+30-33
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,53 @@
1-
# Elefren
1+
# Async Mastodon client library
22

3-
## A Wrapper for the Mastodon API.
3+
[![Build Status](https://github.com/dscottboggs/mastodon-async/actions/workflows/rust.yml/badge.svg)]
4+
[![crates.io](https://img.shields.io/crates/v/mastodon-async.svg)](https://crates.io/crates/mastodon-async)
5+
[![Docs](https://docs.rs/mastodon-async/badge.svg)](https://docs.rs/mastodon-async)
6+
[![MIT/APACHE-2.0](https://img.shields.io/crates/l/mastodon-async.svg)](https://crates.io/crates/mastodon-async)
47

5-
[![Build Status](https://github.com/dscottboggs/elefren/actions/workflows/rust.yml/badge.svg)](https://travis-ci.org/pwoolcoc/elefren)
6-
<!-- [![Coverage Status](https://coveralls.io/repos/github/pwoolcoc/elefren/badge.svg?branch=master&service=github)](https://coveralls.io/github/pwoolcoc/elefren?branch=master) -->
7-
<!-- [![crates.io](https://img.shields.io/crates/v/elefren.svg)](https://crates.io/crates/elefren) -->
8-
<!-- [![Docs](https://docs.rs/elefren/badge.svg)](https://docs.rs/elefren) -->
9-
<!-- [![MIT/APACHE-2.0](https://img.shields.io/crates/l/elefren.svg)](https://crates.io/crates/elefren) -->
8+
[Documentation](https://docs.rs/mastodon-async/)
109

11-
[Documentation](https://docs.rs/elefren/)
12-
13-
A wrapper around the [API](https://github.com/tootsuite/documentation/blob/master/docs/Using-the-API/API.md#tag) for [Mastodon](https://botsin.space/)
10+
A type-safe, async wrapper around the client [API](https://github.com/tootsuite/documentation/blob/master/docs/Using-the-API/API.md#tag)
11+
for [Mastodon](https://botsin.space/)
1412

1513
## Installation
1614

17-
To add `elefren` to your project, add the following to the
15+
To add `mastodon-async` to your project, add the following to the
1816
`[dependencies]` section of your `Cargo.toml`
1917

2018
```toml
21-
elefren = "0.23"
19+
mastodon-async = "1.0"
2220
```
2321

2422
Alternatively, run the following command:
2523

2624
~~~console
27-
$ cargo add elefren
25+
$ cargo add mastodon-async
2826
~~~
2927

3028
## Example
3129

3230
In your `Cargo.toml`, make sure you enable the `toml` feature:
3331

3432
```toml
35-
[dependencies]
36-
elefren = { version = "0.22", features = ["toml"] }
33+
[dependencies.mastodon-async]
34+
version = "1.0"
35+
features = ["toml"]
3736
```
3837

3938
```rust,no_run
4039
// src/main.rs
4140
42-
use std::error::Error;
43-
44-
use elefren::prelude::*;
45-
use elefren::helpers::toml; // requires `features = ["toml"]`
46-
use elefren::helpers::cli;
41+
use mastodon_async::prelude::*;
42+
use mastodon_async::helpers::toml; // requires `features = ["toml"]`
43+
use mastodon_async::{helpers::cli, Result};
4744
4845
#[tokio::main]
49-
async fn main() -> Result<(), Box<dyn Error>> {
46+
async fn main() -> Result<()> {
5047
let mastodon = if let Ok(data) = toml::from_file("mastodon-data.toml") {
5148
Mastodon::from(data)
5249
} else {
53-
register()?
50+
register().await?
5451
};
5552
5653
let you = mastodon.verify_credentials().await?;
@@ -60,14 +57,15 @@ async fn main() -> Result<(), Box<dyn Error>> {
6057
Ok(())
6158
}
6259
63-
fn register() -> Result<Mastodon, Box<dyn Error>> {
60+
async fn register() -> Result<Mastodon> {
6461
let registration = Registration::new("https://botsin.space")
65-
.client_name("elefren-examples")
66-
.build()?;
67-
let mastodon = cli::authenticate(registration)?;
62+
.client_name("mastodon-async-examples")
63+
.build()
64+
.await?;
65+
let mastodon = cli::authenticate(registration).await?;
6866
6967
// Save app data for using on the next run.
70-
toml::to_file(&*mastodon, "mastodon-data.toml")?;
68+
toml::to_file(&mastodon.data, "mastodon-data.toml")?;
7169
7270
Ok(mastodon)
7371
}
@@ -76,24 +74,23 @@ fn register() -> Result<Mastodon, Box<dyn Error>> {
7674
It also supports the [Streaming API](https://docs.joinmastodon.org/api/streaming):
7775

7876
```rust,no_run
79-
use elefren::prelude::*;
80-
use elefren::entities::event::Event;
81-
82-
use std::error::Error;
77+
use mastodon_async::{prelude::*, Result, entities::event::Event};
78+
use futures_util::TryStreamExt;
8379
8480
#[tokio::main]
85-
async fn main() -> Result<(), Box<Error>> {
81+
async fn main() -> Result<()> {
8682
let client = Mastodon::from(Data::default());
8783
8884
client.stream_user()
8985
.await?
90-
.try_for_each(|event| {
86+
.try_for_each(|event| async move {
9187
match event {
9288
Event::Update(ref status) => { /* .. */ },
9389
Event::Notification(ref notification) => { /* .. */ },
9490
Event::Delete(ref id) => { /* .. */ },
9591
Event::FiltersChanged => { /* .. */ },
9692
}
93+
Ok(())
9794
})
9895
.await?;
9996
Ok(())

appveyor.yml

-29
This file was deleted.

docs/book.toml

-8
This file was deleted.

docs/guide/.nojekyll

-1
This file was deleted.

docs/guide/FontAwesome/css/font-awesome.css

-4
This file was deleted.
-135 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)