Crate ddclient_rs

source ·
Expand description

§Direct Decisions API Client

ddclient-rs is a Rust client library for interacting with the Direct Decisions API. It provides a convenient way to access and manipulate voting data using the Direct Decisions API.

The client supports various operations such as creating votings, voting, unvoting, retrieving voting results, and more.

The api specification can be found at https://api.directdecisions.com/v1.

§Features

  • Create and manage votings.
  • Submit votes and retrieve ballots.
  • Modify voting choices.
  • Fetch voting results and analyze outcomes.
  • Handle rate limits and errors gracefully.

§Usage

To use ddclient-rs, add it as a dependency in your Cargo.toml file:

[dependencies]
ddclient-rs = "0.1.0"

Then, import ddclient-rs in your Rust file and use the Client struct to interact with the API.

use ddclient_rs::Client;

#[tokio::main]
async fn main() {
    let client = Client::builder("your-api-key".to_string()).build();

    // Example: Creating a new voting
    let voting = client.create_voting(vec!["Einstein".to_string(), "Newton".to_string()]).await.unwrap();
    println!("Created voting: {:?}", voting);

}

§Error Handling

The client uses custom error types defined in the ddclient_rs::errors, the APIError enum.

§Examples

See the examples/ directory for more example usage of the ddclient-rs.

§Contributions

Contributions are welcome! Please refer to the repository’s CONTRIBUTING.md file for contribution guidelines.

Structs§

  • Represents the strength of a choice compared to another choice in a duel.
  • A client for accessing the Direct Decisions API.
  • A builder for creating an instance of Client.
  • Represents the duel information for 2 choices, as part of the voting results.
  • Represents the rate limit information returned by the API.
  • Represents a voting.
  • Represents the single result for a specific choice.
  • Represents the results of a voting process.

Enums§