Expand description
§Elefren: API Wrapper around the Mastodon API.
Most of the api is documented on Mastodon’s website
use elefren::{helpers::cli, prelude::*};
let registration = Registration::new("https://mastodon.social")
.client_name("elefren_test")
.build()?;
let mastodon = cli::authenticate(registration)?;
println!(
"{:?}",
mastodon
.get_home_timeline()?
.items_iter()
.take(100)
.collect::<Vec<_>>()
);
Elefren also supports Mastodon’s Streaming API:
§Example
use elefren::entities::event::Event;
let client = Mastodon::from(data);
for event in client.streaming_user()? {
match event {
Event::Update(ref status) => { /* .. */ },
Event::Notification(ref notification) => { /* .. */ },
Event::Delete(ref id) => { /* .. */ },
Event::FiltersChanged => { /* .. */ },
}
}
Re-exports§
pub use data::Data;
pub use errors::ApiError;
pub use errors::Error;
pub use errors::Result;
pub use registration::Registration;
pub use requests::AddFilterRequest;
pub use requests::AddPushRequest;
pub use requests::StatusesRequest;
pub use requests::UpdateCredsRequest;
pub use requests::UpdatePushRequest;
pub use status_builder::NewStatus;
pub use status_builder::StatusBuilder;
Modules§
- apps
- Registering your App
- data
- Contains the struct that holds the client auth data
- entities
- Entities returned from the API
- errors
- Errors
- helpers
- Collection of helpers for serializing/deserializing
Data
objects - http_
send - Contains trait for converting
reqwest::Request
s toreqwest::Response
s - page
- Handling multiple pages of entities.
- prelude
- Automatically import the things you need
- registration
- Registering your app.
- requests
- Requests
- scopes
- OAuth Scopes
- status_
builder - Constructing a status
Macros§
- format_
err - Used to easily create errors from strings
Structs§
- Event
Reader - Iterator that produces events from a mastodon streaming API event stream
- Mastodon
- Your mastodon application client, handles all requests to and from Mastodon.
- Mastodon
Unauth - Client that can make unauthenticated calls to a mastodon instance
- WebSocket
- WebSocket newtype so that EventStream can be implemented without coherency issues
Enums§
Traits§
- Event
Stream - A type that streaming events can be read from
- Mastodon
Client - Represents the set of methods that a Mastodon Client can do, so that implementations might be swapped out for testing
- Mastodon
Unauthenticated - Trait that represents clients that can make unauthenticated calls to a mastodon instance