qwed

Crates.ioqwed
lib.rsqwed
version1.0.0
created_at2025-12-31 21:28:19.758085+00
updated_at2025-12-31 21:28:19.758085+00
descriptionRust SDK for QWED Verification Protocol
homepage
repositoryhttps://github.com/QWED-AI/qwed-verification
max_upload_size
id2015409
size53,957
Rahul (rahuldass19)

documentation

README

qwed

Rust SDK for QWED Verification Protocol

crates.io Rust 1.70+

Installation

Add to your Cargo.toml:

[dependencies]
qwed = "1.0"
tokio = { version = "1.0", features = ["rt-multi-thread", "macros"] }

Quick Start

use qwed::QWEDClient;

#[tokio::main]
async fn main() -> Result<(), qwed::Error> {
    let client = QWEDClient::new("qwed_your_api_key");
    
    let result = client.verify("What is 2+2?").await?;
    println!("Verified: {}", result.verified); // true
    println!("Status: {:?}", result.status);   // Verified
    
    Ok(())
}

Verification Methods

Natural Language

let result = client.verify("Is 15% of 200 equal to 30?").await?;

Math Expressions

let result = client.verify_math("x**2 + 2*x + 1 = (x+1)**2").await?;

Logic (QWED-DSL)

let result = client.verify_logic("(AND (GT x 5) (LT y 10))").await?;
// result.result["satisfiability"] = "SAT"

Code Security

let result = client.verify_code(r#"
import os
os.system('rm -rf /')
"#, "python").await?;

Fact Verification

let result = client.verify_fact(
    "Paris is the capital of France",
    "France is a country in Europe. Its capital city is Paris.",
).await?;

SQL Validation

let result = client.verify_sql(
    "SELECT * FROM users WHERE id = 1",
    "CREATE TABLE users (id INT PRIMARY KEY, name TEXT)",
    "postgresql",
).await?;

Batch Verification

use qwed::{BatchItem, VerificationType};

let items = vec![
    BatchItem { query: "2+2=4".into(), r#type: Some(VerificationType::Math) },
    BatchItem { query: "3*3=9".into(), r#type: Some(VerificationType::Math) },
];

let result = client.verify_batch(items).await?;
if let Some(summary) = result.summary {
    println!("Success rate: {:.1}%", summary.success_rate);
}

Client Configuration

use std::time::Duration;

let client = QWEDClient::with_options(
    "qwed_...",
    "https://api.qwed.ai",
    Duration::from_secs(60),
);

Error Handling

use qwed::{QWEDClient, Error};

match client.verify("test").await {
    Ok(result) => println!("Verified: {}", result.verified),
    Err(Error::Auth) => eprintln!("Invalid API key"),
    Err(Error::RateLimit) => eprintln!("Rate limit exceeded"),
    Err(Error::Api { code, message }) => eprintln!("Error {}: {}", code, message),
    Err(e) => eprintln!("Error: {}", e),
}

Types

Type Description
VerificationType Enum: Math, Logic, Stats, Fact, Code, Sql, etc.
VerificationStatus Enum: Verified, Failed, Corrected, Blocked, etc.
VerificationResponse Full verification result
BatchResponse Batch operation result
Error Error enum with Auth, RateLimit, Api variants

Async Runtime

This crate requires tokio as the async runtime:

#[tokio::main]
async fn main() {
    // ...
}

License

Apache 2.0

Commit count: 0

cargo fmt