Crate elefren

Source
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::Requests to reqwest::Responses
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§

EventReader
Iterator that produces events from a mastodon streaming API event stream
Mastodon
Your mastodon application client, handles all requests to and from Mastodon.
MastodonUnauth
Client that can make unauthenticated calls to a mastodon instance
WebSocket
WebSocket newtype so that EventStream can be implemented without coherency issues

Enums§

Language

Traits§

EventStream
A type that streaming events can be read from
MastodonClient
Represents the set of methods that a Mastodon Client can do, so that implementations might be swapped out for testing
MastodonUnauthenticated
Trait that represents clients that can make unauthenticated calls to a mastodon instance