1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
//! # mastodon-async: API Wrapper around the Mastodon API.
//!
//! Most of the api is documented on [Mastodon's website](https://docs.joinmastodon.org/client/intro/)
//!
//! ```no_run
//! use mastodon_async::{helpers::cli, prelude::*};
//! use futures_util::StreamExt;
//!
//! tokio_test::block_on(async {
//! let registration = Registration::new("https://botsin.space")
//! .client_name("mastodon-async_test")
//! .build()
//! .await
//! .unwrap();
//! let mastodon = cli::authenticate(registration).await.unwrap();
//!
//! println!(
//! "{:?}",
//! mastodon
//! .get_home_timeline()
//! .await
//! .unwrap()
//! .items_iter()
//! .take(100)
//! .collect::<Vec<_>>()
//! .await
//! );
//! });
//! ```
//!
//! mastodon-async also supports Mastodon's Streaming API:
//!
//! ## Example
//!
//! ```no_run
//! use mastodon_async::{prelude::*, entities::event::Event};
//! use futures_util::TryStreamExt;
//!
//! let data = Data::default();
//! let client = Mastodon::from(data);
//! tokio_test::block_on(async {
//! let stream = client.stream_user().await.unwrap();
//! stream.try_for_each(|(event, _client)| async move {
//! match event {
//! Event::Update(ref status) => { /* .. */ },
//! Event::Notification(ref notification) => { /* .. */ },
//! Event::Delete(ref id) => { /* .. */ },
//! Event::FiltersChanged => { /* .. */ },
//! }
//! Ok(())
//! }).await.unwrap();
//! });
//! ```
#![deny(
missing_docs,
warnings,
missing_debug_implementations,
missing_copy_implementations,
trivial_casts,
trivial_numeric_casts,
unsafe_code,
unstable_features,
unused_import_braces,
unused_qualifications
)]
#[macro_use]
extern crate doc_comment;
#[macro_use]
extern crate serde_json;
#[macro_use]
extern crate serde;
#[cfg(feature = "env")]
extern crate envy;
#[cfg(feature = "toml")]
extern crate toml as tomlcrate;
#[cfg(test)]
extern crate tempfile;
#[cfg(test)]
#[cfg_attr(all(test, any(feature = "toml", feature = "json")), macro_use)]
extern crate indoc;
use page::Page;
pub use data::Data;
pub use errors::{ApiError, Error, Result};
pub use isolang::Language;
pub use mastodon::{Mastodon, MastodonUnauthenticated};
// pub use mastodon_client::{MastodonClient, MastodonUnauthenticated};
pub use mastodon_async_entities::visibility::Visibility;
pub use registration::Registration;
pub use requests::{
AddFilterRequest, AddPushRequest, StatusesRequest, UpdateCredsRequest, UpdatePushRequest,
};
pub use status_builder::{NewStatus, StatusBuilder};
/// Registering your App
pub mod apps;
/// Contains the struct that holds the client auth data
pub mod data;
/// Entities returned from the API
pub mod entities;
/// Errors
pub mod errors;
/// Event stream generators
pub mod event_stream;
/// Collection of helpers for serializing/deserializing `Data` objects
pub mod helpers;
/// Handling multiple pages of entities.
pub mod page;
/// Registering your app.
pub mod registration;
/// Requests
pub mod requests;
/// OAuth Scopes
pub mod scopes;
/// Constructing a status
pub mod status_builder;
#[macro_use]
mod macros;
/// How much time to wait before checking an endpoint again.
pub mod polling_time;
/// Automatically import the things you need
pub mod prelude {
pub use crate::{
entities::prelude::*,
scopes::Scopes,
Data,
Mastodon,
// MastodonClient,
NewStatus,
Registration,
StatusBuilder,
StatusesRequest,
Visibility,
};
}
/// The mastodon client
pub mod mastodon;