openrtb

Crates.ioopenrtb
lib.rsopenrtb
version0.2.1
sourcesrc
created_at2018-06-13 18:26:13.655857
updated_at2023-01-04 14:29:20.489074
descriptionOpenRTB v2.5 and OpenRTB Dynamic Native Ads v1.2 types for rust.
homepagehttps://github.com/k-bx/openrtb-rust
repositoryhttps://github.com/k-bx/openrtb-rust
max_upload_size
id69985
size132,038
Kon Rybnikov (k-bx)

documentation

https://docs.rs/openrtb/

README

Travis Build Status AppVeyor Build status crates.io docs.rs

openrtb

OpenRTB v2.5 and OpenRTB Dynamic Native Ads v1.2 types for rust. Handles (de)serialization to/from JSON.

Example

extern crate openrtb;
extern crate reqwest;

use std::error::Error;

use openrtb::current::{BidRequest, BidResponse};
use reqwest::StatusCode;

fn main() -> Result<(), Box<Error>> {
    let id = "f9b54eb8-6f3b-11e8-adc0-fa7ae01bbebc".to_string();
    let req = BidRequest::new(id);

    let client = reqwest::Client::new();
    let mut res = client
        .post("https://prebid.adnxs.com/pbs/v1/openrtb2/auction")
        .json(&req)
        .send()?;

    match res.status() {
        StatusCode::OK => {
            let res: BidResponse = res.json()?;
            println!("Received bids for req {}.", res.id);
        }
        StatusCode::NO_CONTENT => {
            println!("No bids.");
        }
        _ => {
            println!("Error: {:?}", res);
        }
    }

    Ok(())
}
Commit count: 69

cargo fmt