iab-specs
An unofficial Rust implementation of various IAB (Interactive Advertising Bureau) specifications.
Overview
iab-specs provides typed Rust data structures for working with IAB advertising specifications. Rather than being just a parser, this library wraps each specification's logic into idiomatic Rust types using serde for serialization/deserialization and FromStr/Display for string conversions.
Currently Supported Specifications
- Ads.txt 1.1 - Authorized Digital Sellers declaration for websites
- App-ads.txt 1.0 - Authorized Digital Sellers declaration for mobile and CTV apps
- Sellers.json 1.0 - Supply chain transparency
Installation
Add iab-specs to your Cargo.toml:
[]
= "0.1"
Or use cargo:
Features
The library uses cargo features to enable/disable specifications:
ads_txt- Ads.txt 1.1 support (enabled by default)app_ads_txt- App-ads.txt 1.0 support (enabled by default, requiresads_txt)sellers_json- Sellers.json 1.0 support (enabled by default)
To use only specific specifications:
[]
# Only ads.txt support
= { = "0.1", = false, = ["ads_txt"] }
# Only app-ads.txt support (automatically includes ads_txt)
= { = "0.1", = false, = ["app_ads_txt"] }
Usage Examples
Ads.txt
Parse and generate ads.txt files:
use ;
use FromStr;
// Parse an ads.txt file
let ads_txt_content = "google.com, pub-1234567890123456, DIRECT, f08c47fec0942fa0";
let ads_txt = from_str?;
// Create an ads.txt programmatically
let ads_txt = builder
.contact
.owner_domain
.systems
.build?;
// Serialize to string
let output = ads_txt.to_string;
App-ads.txt
Parse and generate app-ads.txt files for mobile and CTV applications:
use ;
use FromStr;
// Parse an app-ads.txt file
let app_ads_content = r#"
contact=monetization@mygame.com
subdomain=games.mygame.com
# Primary ad network
google.com, pub-1234567890123456, DIRECT, f08c47fec0942fa0
# Reseller partners
silverssp.com, 9876, RESELLER, f6578439
"#;
let app_ads = from_str?;
// Create an app-ads.txt programmatically
let app_ads = builder
.contact
.subdomain
.systems
.build?;
// Serialize to string
let output = app_ads.to_string;
Note on ads.txt 1.1 vs app-ads.txt 1.0:
App-ads.txt v1.0 is based on an earlier ads.txt specification and does not support the ads.txt 1.1 features:
OWNERDOMAIN(not in app-ads.txt v1.0)MANAGERDOMAIN(not in app-ads.txt v1.0)
Attempting to parse an app-ads.txt file containing these directives will result in an error.
Sellers.json
Parse and generate sellers.json files:
use ;
use FromStr;
// Parse a sellers.json file
let sellers_json = r#"{
"contact_email": "adops@example.com",
"version": "1.0",
"sellers": [
{
"seller_id": "12345",
"seller_type": "publisher",
"name": "Example Publisher",
"domain": "example.com"
}
]
}"#;
let sellers = from_str?;
// Create sellers.json programmatically
let sellers = builder
.contact_email
.version
.sellers
.build?;
// Serialize to JSON string
let output = to_string_pretty?;
Documentation
Full API documentation is available on docs.rs.
For usage examples, please refer to the unit tests in the source code. Each module includes comprehensive test cases demonstrating both serialization and deserialization.
Roadmap
- Ads.txt 1.1
- App-ads.txt 1.0
- Sellers.json 1.0
- OpenRTB 2.5
- OpenRTB 2.6
- OpenRTB 3.0
- Additional IAB specifications (contributions welcome!)
Contributing
Contributions are welcome! Whether it's:
- Adding new IAB specifications
- Improving existing implementations
- Fixing bugs
- Improving documentation
- Adding examples
Please see CONTRIBUTING.md for detailed guidelines on:
- Development setup
- Running tests locally with
act - Code coverage requirements
- Contribution workflow
License
Licensed under Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.