pub struct ObjectDescriptor { /* private fields */ }Expand description
Complete object plus exact ordered block hashes. A digest is not authenticity. Deployment must authenticate this descriptor before admitting a transfer.
Implementations§
Source§impl ObjectDescriptor
impl ObjectDescriptor
Sourcepub fn new(
object_hash: String,
total_bytes: u64,
block_bytes: u32,
block_hashes: Vec<String>,
limits: TransferLimits,
) -> TransferResult<Self>
pub fn new( object_hash: String, total_bytes: u64, block_bytes: u32, block_hashes: Vec<String>, limits: TransferLimits, ) -> TransferResult<Self>
Constructs a version-one descriptor with strict lowercase SHA-256 identities.
Sourcepub fn from_reader(
reader: impl Read,
total_bytes: u64,
block_bytes: u32,
limits: TransferLimits,
) -> TransferResult<Self>
pub fn from_reader( reader: impl Read, total_bytes: u64, block_bytes: u32, limits: TransferLimits, ) -> TransferResult<Self>
Reads an exact bounded object incrementally; no complete-object allocation. Callers own source I/O deadlines and authenticity of the resulting descriptor.
Sourcepub fn validate(&self, limits: TransferLimits) -> TransferResult<()>
pub fn validate(&self, limits: TransferLimits) -> TransferResult<()>
Validates version, arithmetic and all resource/identity bounds.
Sourcepub fn from_json(bytes: &[u8], limits: TransferLimits) -> TransferResult<Self>
pub fn from_json(bytes: &[u8], limits: TransferLimits) -> TransferResult<Self>
Strict bounded JSON; unknown fields/versions fail at this boundary.
Sourcepub fn to_json(&self) -> TransferResult<Vec<u8>>
pub fn to_json(&self) -> TransferResult<Vec<u8>>
Deterministic descriptor serialization, bounded by the validated hash inventory.
Sourcepub fn object_hash(&self) -> &str
pub fn object_hash(&self) -> &str
Full object SHA-256 identity.
Sourcepub fn total_bytes(&self) -> u64
pub fn total_bytes(&self) -> u64
Exact complete object bytes.
Sourcepub fn block_bytes(&self) -> u32
pub fn block_bytes(&self) -> u32
Maximum block length; the last block may be shorter.
Sourcepub fn block_count(&self) -> usize
pub fn block_count(&self) -> usize
Number of complete/incomplete blocks.
Sourcepub fn block_len(&self, index: usize) -> TransferResult<usize>
pub fn block_len(&self, index: usize) -> TransferResult<usize>
Exact length for a valid block index.
Sourcepub fn block_offset(&self, index: usize) -> TransferResult<u64>
pub fn block_offset(&self, index: usize) -> TransferResult<u64>
Offset for a validated block index.
Sourcepub fn verify_block(&self, index: usize, bytes: &[u8]) -> TransferResult<()>
pub fn verify_block(&self, index: usize, bytes: &[u8]) -> TransferResult<()>
Verifies length and digest against the trusted inventory.