eiga

Crates.ioeiga
lib.rseiga
version0.3.0
sourcesrc
created_at2022-08-29 00:15:16.692411
updated_at2022-09-11 20:23:59.16694
descriptionA WIP TMDB API client
homepage
repositoryhttps://github.com/zachcmadsen/eiga
max_upload_size
id654103
size79,426
Zach Madsen (zachcmadsen)

documentation

README

eiga

CI crates.io docs.rs license

eiga is a WIP TMDB API client.

eiga is usable, but it doesn't cover much of the TMDB API yet.

Usage

Add eiga as a dependency in your Cargo.toml:

[dependencies]
eiga = "0.3.0"

Example

This example shows how to get details about a movie. You can find other examples in the examples folder.

use std::env;
use std::error::Error;

use serde::Deserialize;

use eiga::{movie, Client, Tmdb};

// eiga doesn't provide types for endpoint responses. Instead, users provide
// their own structs to deserialize into.
#[derive(Deserialize)]
struct MovieDetails {
    release_date: String,
    title: String,
}

fn main() -> Result<(), Box<dyn Error>> {
    // Create a TMDB client by providing an API access token. Here, the token
    // is stored in the TMDB_TOKEN environment variable.
    let token = env::var("TMDB_TOKEN")?;
    let tmdb = Tmdb::new(token);

    // Build an endpoint to get details about "Tokyo Drifter" (1966). Each
    // endpoint has setter methods for optional query string parameters.
    let tokyo_drifter_id = 45706;
    let movie_details_endpoint =
        movie::Details::new(tokyo_drifter_id).language("en-US");

    // Send the request! Type annotations are required because `send` can
    // deserialize the response to any type that implements `Deserialize`.
    let movie_details: MovieDetails = tmdb.send(&movie_details_endpoint)?;

    assert_eq!(movie_details.title, "Tokyo Drifter");
    assert_eq!(movie_details.release_date, "1966-04-10");

    Ok(())
}

Acknowledgements

  • The design of eiga is mostly based on the design of the gitlab crate. There's a nice writeup on its design here.
Commit count: 39

cargo fmt