샘플
http 1.4.0: http::Uri
검증된 샘플 — cargo http 1.4.0: http::Uri. rust 1 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: Uri::from_str parses full HTTPS URIs exposing scheme…
sha256:466dfb1562d6a5203b6b5969fff199f4510e0720f5eb1db68772871104e8721e
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux · alpine · musl x64 cargo
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-11-17 |
케이스
HOW- 목표
- verify http::Uri in pkg:cargo/http@1.4.0
- 패키지
- 심벌
-
- http::Uri
- 생성일
- 2026-11-17T02:36:30Z
컨트랙트
- Uri::from_str parses full HTTPS URIs exposing scheme, authority, host, port_u16, path, query, and path_and_query
- Uri::from_static constructs compile-time static URIs without runtime error
- Uri::builder assembles scheme, authority, and path_and_query into a serialized Uri equal to its parsed form
- Uri::into_parts and Uri::from_parts decompose and reconstruct modified URIs
- Uri supports Default::default root path, origin-form relative paths, and asterisk-form targets
- Parsing empty or whitespace-containing strings and building scheme-without-authority URIs return Err
파일
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
소스
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "bytes"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
[[package]]
name = "http"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a"
dependencies = [
"bytes",
"itoa",
]
[[package]]
name = "itoa"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
[[package]]
name = "sample-http-uri"
version = "1.0.0"
dependencies = [
"http",
]
[package]
name = "sample-http-uri"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
http = "=1.4.0"
[[bin]]
name = "contract"
path = "test/contract.rs"
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify http::Uri in pkg:cargo/http@1.4.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/http@1.4.0
Demonstrate these symbols/APIs:
- http::Uri
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:45c1f6598897a816d85dc525bf050d7dd21339fcd3400edac6ea503f29b74aa1","contract":["Uri::from_str parses full HTTPS URIs exposing scheme, authority, host, port_u16, path, query, and path_and_query","Uri::from_static constructs compile-time static URIs without runtime error","Uri::builder assembles scheme, authority, and path_and_query into a serialized Uri equal to its parsed form","Uri::into_parts and Uri::from_parts decompose and reconstruct modified URIs","Uri supports Default::default root path, origin-form relative paths, and asterisk-form targets","Parsing empty or whitespace-containing strings and building scheme-without-authority URIs return Err"],"goal":"verify http::Uri in pkg:cargo/http@1.4.0","kind":"HOW","packages":["pkg:cargo/http@1.4.0"],"schemaVersion":1,"symbols":["http::Uri"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/http@1.4.0"],"schemaVersion":1,"subject":"pkg:cargo/http@1.4.0","symbols":["http::Uri"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify http::Uri in pkg:cargo/http@1.4.0",
"kind": "HOW",
"packages": [
"pkg:cargo/http@1.4.0"
],
"symbols": [
"http::Uri"
]
}
//! Clean-room verification sample for http::Uri.
pub use http::Uri;
use http::uri::{PathAndQuery, Scheme};
use http::Uri;
fn main() {
// 1. Parse full URI and inspect scheme, authority, host, port, path, and query
let parsed: Uri = "https://example.com:8443/v1/items?limit=10&sort=asc"
.parse()
.expect("valid full URI should parse");
assert_eq!(parsed.scheme(), Some(&Scheme::HTTPS));
assert_eq!(parsed.scheme_str(), Some("https"));
assert_eq!(
parsed.authority().map(|a| a.as_str()),
Some("example.com:8443")
);
assert_eq!(parsed.host(), Some("example.com"));
assert_eq!(parsed.port_u16(), Some(8443));
assert_eq!(parsed.path(), "/v1/items");
assert_eq!(parsed.query(), Some("limit=10&sort=asc"));
assert_eq!(
parsed.path_and_query().map(|pq| pq.as_str()),
Some("/v1/items?limit=10&sort=asc")
);
// 2. Construct Uri::from_static without runtime error
let static_uri = Uri::from_static("http://localhost:8080/health");
assert_eq!(static_uri.scheme(), Some(&Scheme::HTTP));
assert_eq!(static_uri.host(), Some("localhost"));
assert_eq!(static_uri.port_u16(), Some(8080));
assert_eq!(static_uri.path(), "/health");
assert_eq!(static_uri.query(), None);
// 3. Build a URI via Uri::builder() and verify serialization and equality
let built = Uri::builder()
.scheme("http")
.authority("localhost:8080")
.path_and_query("/health?ready=1")
.build()
.expect("builder with valid parts should succeed");
assert_eq!(built.to_string(), "http://localhost:8080/health?ready=1");
let reparsed: Uri = built.to_string().parse().expect("serialized URI parses");
assert_eq!(built, reparsed);
// 4. Decompose into Parts and reconstruct via Uri::from_parts
let mut parts = built.into_parts();
assert_eq!(parts.scheme, Some(Scheme::HTTP));
parts.path_and_query = Some(PathAndQuery::from_static("/status?ok=true"));
let rebuilt = Uri::from_parts(parts).expect("rebuilding from valid parts succeeds");
assert_eq!(rebuilt.to_string(), "http://localhost:8080/status?ok=true");
assert_eq!(rebuilt.path(), "/status");
assert_eq!(rebuilt.query(), Some("ok=true"));
// 5. Origin-form, asterisk-form, and Default::default() behavior
let default_uri = Uri::default();
assert_eq!(default_uri.path(), "/");
assert!(default_uri.scheme().is_none());
assert!(default_uri.authority().is_none());
let origin: Uri = "/only/path?x=1".parse().expect("origin-form URI parses");
assert!(origin.scheme().is_none());
assert!(origin.authority().is_none());
assert_eq!(origin.path(), "/only/path");
assert_eq!(origin.query(), Some("x=1"));
let asterisk = Uri::from_static("*");
assert_eq!(asterisk.path(), "*");
assert!(asterisk.scheme().is_none());
// 6. Reject malformed URIs and inconsistent URI parts
assert!("".parse::<Uri>().is_err());
assert!("http://example.com/has space".parse::<Uri>().is_err());
let missing_authority_with_scheme = Uri::builder()
.scheme("https")
.path_and_query("/orphan")
.build();
assert!(missing_authority_with_scheme.is_err());
println!("All http::Uri contract assertions passed.");
}
오리진 시더
익명