nupp.runtime.services.digest

Canonical nupp.digest API 1 provider catalog.

Setup imports service here and selects an implementation before requiring nupp.digest. Importing this declaration does not load storage or algorithms. A provider supplies an algorithms map keyed by canonical algorithm name. Each descriptor's name agrees with its key, and each create returns independent owned state. An explicitly selected catalog replaces matching built-in algorithms and may add names; other built-in algorithms remain available. Without selection the facade uses the built-in catalog. Discovery order never selects a provider.

The facade validates and retains descriptors while requiring the module. Lookup, listing, and context creation then use cached descriptors without SPI resolution. Provider state processes chunks incrementally and retains neither input nor output spans. Cleanup consumes state without suspension. Reuse these canonical State and Algorithm identities, including ownership and borrowing signatures. Finalization writes exactly digestSize bytes into the caller's output span. The facade closes state on successful or failed finalization. Standard digest names retain their standard output sizes. MD5 and SHA-1 support interoperability; applications requiring collision resistance must choose an appropriate digest.

Module contents

Types

TypeKindDescription
AlgorithminterfaceImmutable algorithm identity, output metadata, and a factory for fresh state.
ProviderinterfaceA selectable implementation catalog.
StateinterfaceIndependent incremental state; close consumes its ownership without suspension.

Values

ValueKindDescription
servicevariableSelect during setup, before the digest facade loads.

Types#

Algorithminterface#

interface Algorithm
    readonly name: string
    readonly digestSize: integer
    create: function(self: Algorithm): State
end

Immutable algorithm identity, output metadata, and a factory for fresh state.

Methods

create#
create: function(self: Algorithm): State

Creates independent owned state; self is the retained descriptor.

Arguments
NameTypeDescription
selfAlgorithm
Returns
TypeDescription
State

Fields

name#
name: string

Canonical algorithm name, matching the catalog map key.

digestSize#
digestSize: integer

Fixed output size in bytes.

Providerinterface#

interface Provider
    readonly algorithms: {[string]: Algorithm}
end

A selectable implementation catalog. Extra descriptor members are permitted.

Fields

algorithms#
algorithms: {[string]: Algorithm}

Canonical names mapped to checked, independent-state factories.

Stateinterface#

affine interface State is nupp.Closeable
    terminal close: nosuspend function(takes self: State): nil
    update: function(exclusive self: State, borrows bytes: ByteSpan): nil
    finish: function(exclusive self: State, exclusive destination: ByteWriteSpan): nil
end

Independent incremental state; close consumes its ownership without suspension.

Methods

close#
close: nosuspend function(takes self: State): nil

Releases all state resources.

Arguments
NameTypeDescription
takes selfState
Returns
TypeDescription
nil
update#
update: function(exclusive self: State, borrows bytes: ByteSpan): nil

Processes this borrowed chunk without retaining its bytes.

Arguments
NameTypeDescription
exclusive selfState
borrows bytesByteSpan
Returns
TypeDescription
nil
finish#
finish: function(exclusive self: State, exclusive destination: ByteWriteSpan): nil

Writes exactly the descriptor's digestSize bytes. Does not close state; the owning facade closes it on success and on failure.

Arguments
NameTypeDescription
exclusive selfState
exclusive destinationByteWriteSpan
Returns
TypeDescription
nil

Values#

servicevariable#

const service: services.Service<Provider>

Select during setup, before the digest facade loads.