diff options
author | Scott Boggs <scott@tams.tech> | 2022-12-23 12:28:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-23 12:28:35 -0500 |
commit | 62dee5295e213dafa460257d402a622640b1faaa (patch) | |
tree | af7c1e26db11bfb8aa3c9b962d22e9d92ba0bacc | |
parent | 6fb63800d79ed06b0b0411eabde4d618f31092d2 (diff) | |
parent | ca7777c2f835b6437a891d6bf821b490df7678c8 (diff) |
Merge pull request #2 from dscottboggs/fix/examplesv1.0.0
Pre-release tasks
- chang the name of the project from elefren to mastodon-async
- fix and updates some documentation
- fix the examples
69 files changed, 494 insertions, 3889 deletions
diff --git a/.cargo-ok b/.cargo-ok deleted file mode 100644 index b5754e2..0000000 --- a/.cargo-ok +++ /dev/null @@ -1 +0,0 @@ -ok
\ No newline at end of file diff --git a/.clog.toml b/.clog.toml deleted file mode 100644 index a853fbd..0000000 --- a/.clog.toml +++ /dev/null @@ -1,3 +0,0 @@ -[clog] -changelog = "CHANGELOG.md" - diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8d8f57e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -sudo: required -language: rust -dist: trusty -addons: - apt: - packages: - - libssl-dev -cache: - directories: - - $HOME/.cargo -env: - - ELEFREN_FEATURES="--features toml" - - ELEFREN_FEATURES="--features json" - - ELEFREN_FEATURES="--features all" - - ELEFREN_FEATURES="" -os: - - linux - - osx -rust: - - stable - - beta - - nightly -script: - - cargo test $ELEFREN_FEATURES -matrix: - include: - - name: "Coverage" - rust: nightly - before_cache: RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install -f cargo-tarpaulin - script: cargo build --features all - after_success: cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID --features all - - - name: "rustfmt" - rust: nightly - before_script: rustup component add rustfmt-preview - script: cargo fmt --all -- --check - - allow_failures: - - rust: nightly -notifications: - email: - on_success: never diff --git a/CHANGELOG.md b/CHANGELOG.md index d557f50..3dbae99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +<a name="v1.0.0"></a> +## v1.0.0 + +#### Breaking Changes + +* All functions which interact with the API are now async. As a part of this + change, the streaming API now returns a `Stream` instead of an `Iterator`. +* The crate has been renamed to `mastodon-async`. +* Search API v1 has been removed. + +#### Features +* Structured logging + +#### Bug fixes +* Streaming API was incomplete, it now works + <a name="v0.18.0"></a> ## v0.18.0 (2019-01-05) @@ -1,5 +1,5 @@ [package] -name = "elefren" +name = "mastodon-async" version = "1.0.0" authors = ["Aaron Power <theaaronepower@gmail.com>", "Paul Woolcock <paul@woolcock.us>", "D. Scott Boggs <scott@tams.tech>"] description = "A wrapper around the Mastodon API." @@ -8,7 +8,7 @@ keywords = ["api", "web", "social", "mastodon", "wrapper"] categories = ["web-programming", "web-programming::http-client", "api-bindings"] license = "MIT/Apache-2.0" edition = "2021" -repository = "https://github.com/dscottboggs/elefren.git" +repository = "https://github.com/dscottboggs/mastodon-async.git" [package.metadata.docs.rs] features = ["all"] @@ -70,9 +70,11 @@ features = ["io"] tokio-test = "0.4.2" futures-util = "0.3.25" indoc = "1.0" -pretty_env_logger = "0.3.0" skeptic = "0.13" tempfile = "3" +# for examples: +femme = "2.2.1" +html2text = "0.4.4" [build-dependencies.skeptic] version = "0.13" diff --git a/LICENCE-APACHE b/LICENCE-APACHE index 97fdf99..176ce52 100644 --- a/LICENCE-APACHE +++ b/LICENCE-APACHE @@ -1,4 +1,5 @@ Copyright 2016 Aaron Power +Copyright © 2022 D. Scott Boggs Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/LICENCE-MIT b/LICENCE-MIT index 0e95451..2be69e9 100644 --- a/LICENCE-MIT +++ b/LICENCE-MIT @@ -1,6 +1,7 @@ MIT License (MIT) Copyright (c) 2016 Aaron Power +Copyright © 2022 D. Scott Boggs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -1,30 +1,28 @@ -# Elefren +# Async Mastodon client library -## A Wrapper for the Mastodon API. +[![Build Status](https://github.com/dscottboggs/mastodon-async/actions/workflows/rust.yml/badge.svg)] +[![crates.io](https://img.shields.io/crates/v/mastodon-async.svg)](https://crates.io/crates/mastodon-async) +[![Docs](https://docs.rs/mastodon-async/badge.svg)](https://docs.rs/mastodon-async) +[![MIT/APACHE-2.0](https://img.shields.io/crates/l/mastodon-async.svg)](https://crates.io/crates/mastodon-async) -[![Build Status](https://github.com/dscottboggs/elefren/actions/workflows/rust.yml/badge.svg)](https://travis-ci.org/pwoolcoc/elefren) -<!-- [![Coverage Status](https://coveralls.io/repos/github/pwoolcoc/elefren/badge.svg?branch=master&service=github)](https://coveralls.io/github/pwoolcoc/elefren?branch=master) --> -<!-- [![crates.io](https://img.shields.io/crates/v/elefren.svg)](https://crates.io/crates/elefren) --> -<!-- [![Docs](https://docs.rs/elefren/badge.svg)](https://docs.rs/elefren) --> -<!-- [![MIT/APACHE-2.0](https://img.shields.io/crates/l/elefren.svg)](https://crates.io/crates/elefren) --> +[Documentation](https://docs.rs/mastodon-async/) -[Documentation](https://docs.rs/elefren/) - -A wrapper around the [API](https://github.com/tootsuite/documentation/blob/master/docs/Using-the-API/API.md#tag) for [Mastodon](https://botsin.space/) +A type-safe, async wrapper around the client [API](https://github.com/tootsuite/documentation/blob/master/docs/Using-the-API/API.md#tag) +for [Mastodon](https://botsin.space/) ## Installation -To add `elefren` to your project, add the following to the +To add `mastodon-async` to your project, add the following to the `[dependencies]` section of your `Cargo.toml` ```toml -elefren = "0.23" +mastodon-async = "1.0" ``` Alternatively, run the following command: ~~~console -$ cargo add elefren +$ cargo add mastodon-async ~~~ ## Example @@ -32,25 +30,24 @@ $ cargo add elefren In your `Cargo.toml`, make sure you enable the `toml` feature: ```toml -[dependencies] -elefren = { version = "0.22", features = ["toml"] } +[dependencies.mastodon-async] +version = "1.0" +features = ["toml"] ``` ```rust,no_run // src/main.rs -use std::error::Error; - -use elefren::prelude::*; -use elefren::helpers::toml; // requires `features = ["toml"]` -use elefren::helpers::cli; +use mastodon_async::prelude::*; +use mastodon_async::helpers::toml; // requires `features = ["toml"]` +use mastodon_async::{helpers::cli, Result}; #[tokio::main] -async fn main() -> Result<(), Box<dyn Error>> { +async fn main() -> Result<()> { let mastodon = if let Ok(data) = toml::from_file("mastodon-data.toml") { Mastodon::from(data) } else { - register()? + register().await? }; let you = mastodon.verify_credentials().await?; @@ -60,14 +57,15 @@ async fn main() -> Result<(), Box<dyn Error>> { Ok(()) } -fn register() -> Result<Mastodon, Box<dyn Error>> { +async fn register() -> Result<Mastodon> { let registration = Registration::new("https://botsin.space") - .client_name("elefren-examples") - .build()?; - let mastodon = cli::authenticate(registration)?; + .client_name("mastodon-async-examples") + .build() + .await?; + let mastodon = cli::authenticate(registration).await?; // Save app data for using on the next run. - toml::to_file(&*mastodon, "mastodon-data.toml")?; + toml::to_file(&mastodon.data, "mastodon-data.toml")?; Ok(mastodon) } @@ -76,24 +74,23 @@ fn register() -> Result<Mastodon, Box<dyn Error>> { It also supports the [Streaming API](https://docs.joinmastodon.org/api/streaming): ```rust,no_run -use elefren::prelude::*; -use elefren::entities::event::Event; - -use std::error::Error; +use mastodon_async::{prelude::*, Result, entities::event::Event}; +use futures_util::TryStreamExt; #[tokio::main] -async fn main() -> Result<(), Box<Error>> { +async fn main() -> Result<()> { let client = Mastodon::from(Data::default()); client.stream_user() .await? - .try_for_each(|event| { + .try_for_each(|event| async move { match event { Event::Update(ref status) => { /* .. */ }, Event::Notification(ref notification) => { /* .. */ }, Event::Delete(ref id) => { /* .. */ }, Event::FiltersChanged => { /* .. */ }, } + Ok(()) }) .await?; Ok(()) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 6087033..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,29 +0,0 @@ -environment: - matrix: - - TARGET: x86_64-pc-windows-msvc - OTHER_TARGET: i686-pc-windows-msvc - MAKE_TARGETS: test-unit-x86_64-pc-windows-msvc - TOOLCHAIN: stable - - TARGET: x86_64-pc-windows-msvc - OTHER_TARGET: i686-pc-windows-msvc - MAKE_TARGETS: test-unit-x86_64-pc-windows-msvc - TOOLCHAIN: beta - - TARGET: x86_64-pc-windows-msvc - OTHER_TARGET: i686-pc-windows-msvc - MAKE_TARGETS: test-unit-x86_64-pc-windows-msvc - TOOLCHAIN: nightly - -install: - - appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe - - rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain %TOOLCHAIN% - - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin - - rustup target add %OTHER_TARGET% - - rustc -V - - cargo -V - -clone_depth: 1 - -build: false - -test_script: - - cargo test --features all diff --git a/docs/book.toml b/docs/book.toml deleted file mode 100644 index a711481..0000000 --- a/docs/book.toml +++ /dev/null @@ -1,8 +0,0 @@ -[book] -authors = ["Paul Woolcock"] -multilingual = false -src = "src" -title = "Elefren Guide" - -[build] -build-dir = "guide" diff --git a/docs/guide/.nojekyll b/docs/guide/.nojekyll deleted file mode 100644 index 8631215..0000000 --- a/docs/guide/.nojekyll +++ /dev/null @@ -1 +0,0 @@ -This file makes sure that Github Pages doesn't process mdBook's output.
\ No newline at end of file diff --git a/docs/guide/FontAwesome/css/font-awesome.css b/docs/guide/FontAwesome/css/font-awesome.css deleted file mode 100644 index ee4e978..0000000 --- a/docs/guide/FontAwesome/css/font-awesome.css +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * Font Awesome 4.4.0 by @davegandy - http://fontawesome.io - @fontawesome - * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) - */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.4.0');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.4.0') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff2?v=4.4.0') format('woff2'),url('../fonts/fontawesome-webfont.woff?v=4.4.0') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.4.0') format('truetype'),url('../fonts/fontawesome-webfont.svg?v=4.4.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left{margin-right:.3em}.fa.fa-pull-right{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{ |