| Crates.io | switchboard-protos |
| lib.rs | switchboard-protos |
| version | 0.2.4 |
| created_at | 2021-04-13 13:16:50.597263+00 |
| updated_at | 2025-11-10 19:40:52.097945+00 |
| description | Protobuf definitions for Switchboard oracle job schemas |
| homepage | |
| repository | https://github.com/switchboard-xyz/sbv3 |
| max_upload_size | |
| id | 382863 |
| size | 94,663 |
Protobuf definitions for Switchboard oracle job schemas.
This crate provides Protocol Buffer definitions and Rust bindings for Switchboard's oracle job specification system. It enables developers to define, serialize, and deserialize complex oracle jobs that can fetch data from various sources, transform it, and aggregate results.
Add this to your Cargo.toml:
[dependencies]
switchboard-protos = "0.2.0"
use switchboard_protos::oracle_job::{OracleJob, Task, HttpTask};
// Create a simple HTTP task
let http_task = HttpTask {
url: Some("https://api.example.com/price".to_string()),
method: Some(1), // METHOD_GET
..Default::default()
};
// Wrap it in a Task
let task = Task {
task: Some(oracle_job::task::Task::HttpTask(http_task)),
};
// Create an OracleJob with the task
let job = OracleJob {
tasks: vec![task],
weight: Some(1),
};
// Serialize to JSON
let json = serde_json::to_string(&job).unwrap();
use switchboard_protos::oracle_job::{OracleFeed, OracleJob};
let feed = OracleFeed {
name: Some("SOL/USD Price Feed".to_string()),
jobs: vec![/* your oracle jobs */],
min_oracle_samples: Some(3),
min_job_responses: Some(2),
max_job_range_pct: Some(100),
};
The library supports numerous task types for building sophisticated oracle jobs:
# Clone the repository
git clone https://github.com/switchboard-xyz/sbv3
cd sbv3/protos
# Build the crate
cargo build
# Run tests
cargo test
# Check for linting issues
cargo clippy
# Format code
cargo fmt
The build process is fully automated via build.rs:
protoc (no system installation needed)job_schemas.proto using prostpbjson.
├── build.rs # Build script for protobuf generation
├── Cargo.toml # Package manifest
├── job_schemas.proto # Protobuf definitions
├── buf.gen.yaml # Buf configuration
├── README.md # This file
└── src/
└── lib.rs # Library entry point
For complete examples and integration patterns, see the Switchboard documentation.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
For questions and support: