|
|
|
@ -22,34 +22,24 @@ To add `elefren` to your project, add the following to the |
|
|
|
|
elefren = "0.20" |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
## Usage |
|
|
|
|
|
|
|
|
|
To use this crate in your project, add this to your crate root (lib.rs, main.rs, etc): |
|
|
|
|
|
|
|
|
|
```rust,ignore |
|
|
|
|
extern crate elefren; |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
## Example |
|
|
|
|
|
|
|
|
|
In your `Cargo.toml`, make sure you enable the `toml` feature: |
|
|
|
|
|
|
|
|
|
```toml |
|
|
|
|
[dependencies] |
|
|
|
|
elefren = { version = "0.19", features = ["toml"] } |
|
|
|
|
elefren = { version = "0.20", features = ["toml"] } |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
```rust,no_run |
|
|
|
|
// src/main.rs |
|
|
|
|
extern crate elefren; |
|
|
|
|
|
|
|
|
|
use std::error::Error; |
|
|
|
|
|
|
|
|
|
use elefren::prelude::*; |
|
|
|
|
use elefren::helpers::toml; // requires `features = ["toml"]` |
|
|
|
|
use elefren::helpers::cli; |
|
|
|
|
|
|
|
|
|
fn main() -> Result<(), Box<Error>> { |
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> { |
|
|
|
|
let mastodon = if let Ok(data) = toml::from_file("mastodon-data.toml") { |
|
|
|
|
Mastodon::from(data) |
|
|
|
|
} else { |
|
|
|
@ -63,7 +53,7 @@ fn main() -> Result<(), Box<Error>> { |
|
|
|
|
Ok(()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn register() -> Result<Mastodon, Box<Error>> { |
|
|
|
|
fn register() -> Result<Mastodon, Box<dyn Error>> { |
|
|
|
|
let registration = Registration::new("https://mastodon.social") |
|
|
|
|
.client_name("elefren-examples") |
|
|
|
|
.build()?; |
|
|
|
|