Expand description
Shared protocol-facing types used by Shardline clients, storage adapters, and the HTTP server.
This crate keeps the wire-level contracts small and explicit:
ShardlineHashstores validated 32-byte hashes and canonical lowercase hexadecimal text.ByteRangeandChunkRangevalidate range boundaries before they reach storage code.TokenSignersigns and verifies scoped bearer tokens without exposing secret material in debug output.RepositoryScopeties provider-issued tokens to one repository and, optionally, one revision.
§Example
use shardline_protocol::{
RepositoryProvider, RepositoryScope, TokenClaims, TokenScope, TokenSigner,
};
let repository =
RepositoryScope::new(RepositoryProvider::GitHub, "acme", "assets", Some("main"))?;
let claims = TokenClaims::new(
"shardline",
"alice",
TokenScope::Read,
repository,
1_700_000_600,
)?;
let signer = TokenSigner::new(b"development-only-signing-key-32bytes")?;
let token = signer.sign(&claims)?;
let verified = signer.verify_at(&token, 1_700_000_000)?;
assert_eq!(verified.subject(), "alice");
assert_eq!(verified.repository().owner(), "acme");
assert!(verified.scope().allows_read());Structs§
- Byte
Range - Inclusive byte range.
- Chunk
Range - End-exclusive chunk index range.
- Repository
Scope - Repository and revision scope encoded into a token.
- Secret
Bytes - Zeroizing byte-oriented secret material.
- Secret
String - Zeroizing UTF-8 secret material.
- Shardline
Hash - A 32-byte protocol hash.
- Token
Claims - Signed token claims used by the Shardline API.
- Token
Signer - Local token signer and verifier.
Enums§
- Hash
Parse Error - Hash parsing failure.
- Http
Range Parse Error - Reconstruction request range parse failure.
- Range
Error - Range construction failure.
- Repository
Provider - Provider family encoded into a scoped token.
- Token
Claims Error - Token claim validation failure.
- Token
Codec Error - Token signing or verification failure.
- Token
Scope - CAS token scope.
Functions§
- parse_
bool - Parses a boolean value from common operator-friendly strings.
- parse_
http_ byte_ range - Parses a reconstruction
Rangeheader into an inclusive byte range. - unix_
now_ seconds_ lossy - Returns the current Unix timestamp in seconds.