Silk

silk/trust_snapshot

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc.

Bounded immutable owners for explicit trust-anchor sequences.

When to use

Use fromAnchors when the application already owns explicit authorities. Use fromPem to import strict certificate PEM as unconstrained anchors. Use copy or combine when a new owner must survive release of its source snapshots.

Details

A snapshot preserves every anchor, restriction, duplicate, and input position. All limits are inclusive. Zero permits no corresponding resource. An empty anchor vector is valid explicit trust that authenticates no peer.

Gotchas

A snapshot stores explicit authority only. It does not validate a path, identity, time, revocation state, or OS trust policy. Empty or whitespace-only PEM remains invalid.

Import as TrustSnapshot with import silk.trust_snapshot { TrustSnapshot }.

Public declarations: 7.

SnapshotLimits

pub struct SnapshotLimits

Inclusive budgets for one complete trust snapshot.

Field anchors

pub anchors: usize

Maximum anchor count, including duplicate certificate values.

Field encodedBytes

pub encodedBytes: usize

Maximum aggregate certificate and configured-constraint bytes.

Associated function SnapshotLimits.defaults

pub fn defaults() -> SnapshotLimits

Returns finite defaults of 1024 anchors and 8 MiB of retained encoded data.

Implementation Copy for SnapshotLimits

impl Copy for SnapshotLimits

TrustLoadLimits

pub struct TrustLoadLimits

Inclusive strict-decoder and snapshot budgets for one trust-source load.

Field decode

pub decode: DecodeLimits

Bounds used by strict PEM, DER, and certificate decoding.

Field snapshot

pub snapshot: SnapshotLimits

Bounds used by the complete returned snapshot.

Associated function TrustLoadLimits.defaults

pub fn defaults() -> TrustLoadLimits

Returns the finite certificate-decoder and snapshot defaults.

Implementation Copy for TrustLoadLimits

impl Copy for TrustLoadLimits

TrustLimitKind

pub enum TrustLimitKind

A bounded trust-source resource category.

AnchorCount

AnchorCount = 0

The complete snapshot has too many anchors, including duplicates.

EncodedBytes

EncodedBytes = 1

The aggregate certificate and configured-constraint bytes exceed the budget.

InputBytes

InputBytes = 2

A native provider input exceeds its acquisition budget.

TrustConfigurationReason

pub enum TrustConfigurationReason

A rejected native trust-source configuration rule.

EmptyRoot

EmptyRoot = 0

An explicit native root path has no bytes.

NonAbsoluteRoot

NonAbsoluteRoot = 1

An explicit native root path is not absolute.

NulRoot

NulRoot = 2

An explicit native root path contains a zero byte.

PathBytes

PathBytes = 3

A native root path exceeds its byte budget.

TrustFileOperation

pub enum TrustFileOperation

A native trust-source file stage.

Open

Open = 0

Opening the configured trust file failed.

Read

Read = 1

Reading the configured trust file failed.

Close

Close = 2

Closing the configured trust file failed.

TrustSourceError

pub union TrustSourceError

A semantic trust-source failure that does not include allocation refusal.

Decode

TrustSourceError.Decode { error: DecodeError }: TrustSourceError

Strict PEM, DER, or certificate decoding failed at the retained decoder location.

Field error

pub error: DecodeError

The complete structured decoder failure.

LimitExceeded

TrustSourceError.LimitExceeded { kind: TrustLimitKind, limit: usize }: TrustSourceError

A finite trust-source budget was exceeded.

Field kind

pub kind: TrustLimitKind

The exhausted resource category.

Field limit

pub limit: usize

The inclusive configured budget.

InvalidConfiguration

TrustSourceError.InvalidConfiguration { reason: TrustConfigurationReason }: TrustSourceError

A native provider configuration is invalid.

Field reason

pub reason: TrustConfigurationReason

The rejected configuration rule.

File

TrustSourceError.File { operation: TrustFileOperation, error: FileError }: TrustSourceError

A native provider file operation failed.

Field operation

pub operation: TrustFileOperation

The failed file stage.

Field error

pub error: FileError

The complete portable file failure with its provider code.

TrustSnapshot

pub struct TrustSnapshot

One immutable independently owned sequence of explicit trust authorities.

Details

The snapshot preserves input order and duplicates. Each borrowed anchor remains valid only while this snapshot remains valid. Construction does not inspect certificate semantics.

Associated function TrustSnapshot.fromAnchors

pub fn fromAnchors(anchors: silk/vector.Vector<silk/trust_anchor.TrustAnchor>, limits: SnapshotLimits) -> silk/result.Result<silk/trust_snapshot.TrustSnapshot, silk/trust_snapshot.TrustSourceError>

Consumes a complete anchor vector after allocation-free count and byte-budget validation.

Details

Success preserves the vector allocation, order, duplicates, and configured restrictions. Failure releases the consumed input and publishes no snapshot. Empty explicit trust is valid.

Associated function TrustSnapshot.fromPem

pub effect<'life0> fn fromPem<'life0>(input: &'life0 [u8], limits: TrustLoadLimits) -> silk/result.Result<silk/trust_snapshot.TrustSnapshot, silk/trust_snapshot.TrustSourceError> ! OutOfMemoryError ? &mut Allocator

Strictly decodes certificate PEM and moves each certificate into an unconstrained anchor.

Details

The result preserves order and duplicates. It reparses no DER and copies no certificate after decoding. Decoder failures retain their structured locations. Allocation refusal remains an OutOfMemoryError Effect failure. Every failure publishes no snapshot.

Gotchas

Empty or whitespace-only PEM is invalid. Import assigns explicit authority but does not authenticate a path or reproduce OS trust policy.

Method TrustSnapshot.anchors

pub fn anchors<'life0>(self: &'life0 TrustSnapshot) -> &'life0 [silk/trust_anchor.TrustAnchor]

Borrows all anchors in their original order, including every duplicate.

Method TrustSnapshot.copy

pub effect<'life0> fn copy<'life0>(self: &'life0 TrustSnapshot, limits: SnapshotLimits) -> silk/result.Result<silk/trust_snapshot.TrustSnapshot, silk/trust_snapshot.TrustSourceError> ! OutOfMemoryError ? &mut Allocator

Creates an independently owned copy under the supplied inclusive limits.

Details

Every certificate and configured constraint is copied. Allocation refusal releases partial output and leaves this snapshot unchanged.

Associated function TrustSnapshot.combine

pub effect<'env> fn combine<'life0: 'env, 'life1: 'env, 'env>(primary: &'life0 silk/trust_snapshot.TrustSnapshot, additional: &'life1 silk/trust_snapshot.TrustSnapshot, limits: SnapshotLimits) -> silk/result.Result<silk/trust_snapshot.TrustSnapshot, silk/trust_snapshot.TrustSourceError> ! OutOfMemoryError ? &mut Allocator

Copies primary anchors, then additional anchors, into one independent owner.

Details

The operation preserves every duplicate and configured restriction. It does not merge equal certificate DER. A less-restricted additional authority can therefore widen trust.

On this page