iab_specs/
lib.rs

1//! ## Module Organization
2//!
3//! - [`adcom`] - AdCOM 1.0 enumerations (device types, auction types, protocols, etc.)
4//! - [`openrtb`] - OpenRTB 2.5, 2.6, 3.0, and Native Ads 1.2 specifications
5//!   - [`openrtb::v25`] - OpenRTB 2.5 specification
6//!   - [`openrtb::v26`] - OpenRTB 2.6 with CTV and DOOH support
7//!   - [`openrtb::v30`] - OpenRTB 3.0 with layered architecture
8//!   - [`openrtb::native`] - OpenRTB Native Ads 1.2 specification
9//!   - [`openrtb::common`] - Common objects shared between versions
10//! - [`ads_txt`] - Ads.txt 1.1 parser and generator
11//! - [`app_ads_txt`] - App-ads.txt 1.0 parser and generator
12//! - [`sellers_json`] - Sellers.json 1.0 parser and generator
13//!
14//! ## Extension Trait
15//!
16//! The [`Extension`] trait provides a flexible mechanism for adding custom fields to IAB
17//! specification objects throughout the crate. This is essential for:
18//! - **Vendor-specific data**: Add custom fields for your platform
19//! - **Internal tracking**: Include business-specific identifiers
20//! - **Experimental features**: Test new capabilities without spec changes
21//! - **Custom workflows**: Extend objects with application-specific data
22//!
23//! ### Types Supporting Extensions
24//!
25//! Many types across the crate support generic extensions via the `Ext` type parameter:
26//!
27//! - **AdCOM types**: [`adcom::media::Ad`], [`adcom::placement::Placement`], [`adcom::context::Site`],
28//!   [`adcom::context::App`], [`adcom::context::User`], [`adcom::context::Device`], and many more
29//! - **OpenRTB 2.5/2.6**: [`openrtb::v25::BidRequest`], [`openrtb::v25::BidResponse`],
30//!   [`openrtb::v25::Imp`], [`openrtb::v25::Banner`], [`openrtb::v25::Video`], and many more
31//! - **OpenRTB 3.0**: [`openrtb::v30::Request`], [`openrtb::v30::Response`], [`openrtb::v30::Item`],
32//!   [`openrtb::v30::Bid`], and many more
33//!
34//! ### Quick Examples
35//!
36//! **Using default JSON extensions:**
37//!
38//! ```
39//! #[cfg(feature = "adcom")]
40//! {
41//! use iab_specs::adcom::media::Ad;
42//! # use std::error::Error;
43//! # fn main() -> Result<(), Box<dyn Error>> {
44//!
45//! let ad = Ad::builder()
46//!     .id(Some("ad123".to_string()))
47//!     .ext(Some(Box::new(serde_json::json!({
48//!         "vendor_id": "acme-123",
49//!         "campaign_type": "seasonal"
50//!     }))))
51//!     .build()?;
52//! # Ok(())
53//! # }
54//! }
55//! ```
56//!
57//! **Using custom typed extensions:**
58//!
59//! ```
60//! #[cfg(feature = "adcom")]
61//! {
62//! use iab_specs::adcom::media::{Ad, AdBuilder};
63//! use serde::{Deserialize, Serialize};
64//! use derive_builder::Builder;
65//! # use std::error::Error;
66//! # fn main() -> Result<(), Box<dyn Error>> {
67//!
68//! #[derive(Builder, Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
69//! struct MyAdExt {
70//!     vendor_id: String,
71//!     priority: u8,
72//! }
73//!
74//! impl MyAdExt {
75//!     pub fn builder() -> MyAdExtBuilder {
76//!         MyAdExtBuilder::create_empty()
77//!     }
78//! }
79//!
80//! let ext = MyAdExt::builder()
81//!     .vendor_id("acme-123".to_string())
82//!     .priority(5)
83//!     .build()?;
84//!
85//! // Use AdBuilder with type parameter for custom extensions
86//! let ad = AdBuilder::default()
87//!     .id(Some("ad123".to_string()))
88//!     .ext(Some(Box::new(ext)))
89//!     .build()?;
90//! # Ok(())
91//! # }
92//! }
93//! ```
94//!
95//! For complete documentation and more examples, see the [`Extension`] trait documentation.
96
97#[cfg(feature = "adcom")]
98pub mod adcom;
99#[cfg(feature = "ads_txt")]
100pub mod ads_txt;
101#[cfg(feature = "app_ads_txt")]
102pub mod app_ads_txt;
103mod errors;
104#[cfg(any(feature = "openrtb_25", feature = "openrtb_26", feature = "openrtb_30"))]
105pub mod openrtb;
106#[cfg(feature = "sellers_json")]
107pub mod sellers_json;
108pub(crate) mod utils;
109
110pub use errors::*;
111pub use utils::*;