Skip to main content

Crate shardline_server_core

Crate shardline_server_core 

Source
Expand description

Shared core types for the Shardline server ecosystem.

This crate contains pure data structures and constants that are shared between the server crate and potential future crate extractions.

§Quick start

Store a content-addressed object under a validated key. This example uses a blackhole store, which discards all writes and performs no I/O:

use shardline_protocol::ShardlineHash;
use shardline_server_core::ServerObjectStore;
use shardline_storage::{ObjectBody, ObjectIntegrity, ObjectKey, ObjectStore, PutOutcome};

let store = ServerObjectStore::blackhole();
let key = ObjectKey::parse("chunks/aa/bb/example.xorb")?;

let hash = ShardlineHash::from_bytes([7; 32]);
let body = ObjectBody::from_slice(b"serialized chunk bytes");
let integrity = ObjectIntegrity::new(hash, body.as_slice().len() as u64);

assert_eq!(
    ObjectStore::put_if_absent(&store, &key, body, &integrity)?,
    PutOutcome::Inserted
);
assert!(!ObjectStore::contains(&store, &key)?);

For filesystem-backed storage, use ServerObjectStore::local (see its documentation for a no_run example).

Re-exports§

pub use auth_capability::AuthorizedRepository;
pub use auth_capability::scope_allows;
pub use object_store::BoundedObjectReadError;
pub use object_store::MaterializedObject;
pub use object_store::OpsRecordKind;
pub use object_store::OpsRecordStore;
pub use object_store::ServerObjectStore;
pub use object_store::ServerObjectStoreError;
pub use object_store::read_full_object;
pub use validation::chunk_hash;
pub use validation::chunk_hash_from_chunk_object_key_if_present;
pub use validation::chunk_object_key;
pub use validation::content_hash;
pub use ops::ParseStoredFileRecordError;
pub use ops::parse_stored_file_record_bytes;
pub use ops::provider_directory;

Modules§

at_rest
Shared at-rest encryption envelope (AES-256-GCM) for sensitive configuration values.
auth
Authentication and authorization types used by the Shardline server.
auth_capability
Typed, repo-scoped authorization capabilities.
object_store
ops
protocol_support
server_frontend
Runtime protocol frontends served by the Shardline server.
validation

Structs§

AuthContext
Verified request authorization context.
Ed25519AuthProvider
Ed25519 asymmetric-key authentication provider.
LocalHmacProvider
Shared-key token provider using HMAC-SHA256.
PassthroughProvider
Trust-all authentication provider for development mode.
RebuildOverflowError
Arithmetic overflow during rebuild operations.
ShardMetadataLimits
Bounded-parser limits for native Xet shard metadata.
ValidateContentHashError
Content hash validation failure.
ValidateIdentifierError
File identifier validation failure.
VerifiedAuthContext
Verified request authorization context, mintable only by the auth layer.

Enums§

AuthError
Authentication provider failure.
InvalidLifecycleMetadataError
Lifecycle metadata consistency failure.
InvalidReconstructionResponseError
Reconstruction response shape failure.
InvalidSerializedShardError
Serialized shard validation failure.

Constants§

DEFAULT_LOCAL_GC_RETENTION_SECONDS
Default retention window for new local quarantine candidates.
DEFAULT_MAX_SHARD_FILES
Default bounded-parser limits for native Xet shard metadata.
DEFAULT_MAX_SHARD_RECONSTRUCTION_TERMS
Default maximum shard reconstruction terms.
DEFAULT_MAX_SHARD_XORBS
Default maximum shard xorb sections.
DEFAULT_MAX_SHARD_XORB_CHUNKS
Default maximum shard xorb chunk records.
DEFAULT_SHARD_METADATA_LIMITS
Default bounded-parser limits for native Xet shard metadata.
MAX_LOCAL_RECORD_METADATA_BYTES
Maximum allowed stored file record metadata size in bytes.

Traits§

AuthProvider
Provider-agnostic authentication trait.

Functions§

checked_add
Checked addition returning an error on overflow.
checked_increment
Checked increment returning an error on overflow.
unix_now_seconds_checked
Returns the current Unix time in seconds, or an error if the system clock is before the Unix epoch.
validate_content_hash
Validates that a content hash is exactly 64 lowercase hex characters.
validate_content_hash_with
Validates that a content hash is exactly 64 lowercase hex characters.
validate_identifier
Validates that a file identifier is safe for use as a single path component.