Skip to main content

StaticBackendToken

Struct StaticBackendToken 

Source
pub struct StaticBackendToken { /* private fields */ }
Expand description

Non-forgeable, thread-bound proof that a static SIMD backend passed its KAT.

The token bypasses runtime CPU probing only. It does not bypass bounds, canonicality, backend health, quarantine, or reporting. Kernel operations are added to this contract by the architecture admission commits that follow Commit 24.

The raw-pointer marker deliberately makes this value neither Send nor Sync; deployment evidence applies to the thread that constructed it.

let token = base64_ng::StaticBackendToken::for_compiled_target().unwrap();
std::thread::spawn(move || drop(token));

Implementations§

Source§

impl StaticBackendToken

Source

pub fn for_compiled_target() -> Option<Self>

Selects the strongest backend proven by compile-time target features.

Returns None when the build lacks a complete feature bundle, pointer-width atomics, or a passing known-answer test.

Source

pub unsafe fn assume_supported(backend: Backend) -> Option<Self>

Constructs a token from deployment-supplied backend evidence.

§Safety

Before calling, the deployment must prove that this thread’s CPU and OS vector state support every feature returned by Backend::required_cpu_features, that the ABI preserves the required vector state, and that migration cannot move this thread to an incompatible CPU. A false attestation can execute an unsupported instruction during the mandatory KAT and terminate the process.

Source

pub const fn backend(&self) -> Backend

Returns the exact backend represented by this token.

Source

pub const fn health_generation(&self) -> usize

Returns the health generation borrowed by this token.

Source

pub fn is_valid(&self) -> bool

Returns whether quarantine and generation state still validate it.

This is an admission snapshot, not synchronous cancellation. An invocation that already observed a healthy generation may finish while another thread quarantines that backend.

Source

pub fn encode_standard<const PAD: bool>( &self, input: &[u8], output: &mut [u8], ) -> Result<usize, EncodeError>

Encodes with the statically admitted Standard-alphabet backend.

Commits 25, 26, and 29 enable direct SSSE3/SSE4.1, AVX2, AVX-512 VBMI, and little-endian AArch64 NEON execution. Other token backends, or a token invalidated by quarantine, use the scalar encoder. The checked-backend feature applies the same per-call redundant scalar comparison and quarantine policy as automatic dispatch.

Source

pub fn encode_url_safe<const PAD: bool>( &self, input: &[u8], output: &mut [u8], ) -> Result<usize, EncodeError>

Encodes with the statically admitted URL-safe-alphabet backend.

Commits 25, 26, and 29 enable direct SSSE3/SSE4.1, AVX2, AVX-512 VBMI, and little-endian AArch64 NEON execution. Other token backends, or a token invalidated by quarantine, use the scalar encoder. The checked-backend feature applies the same per-call redundant scalar comparison and quarantine policy as automatic dispatch.

Source

pub fn decode_standard<const PAD: bool>( &self, input: &[u8], output: &mut [u8], ) -> Result<usize, DecodeError>

Decodes strict Standard Base64 with the statically admitted backend.

Commits 27, 28, and 29 enable direct SSSE3/SSE4.1, AVX2, AVX-512 VBMI, and little-endian AArch64 NEON execution. Invalid input retains the ordinary strict decoder’s exact diagnostics. Direct SIMD blocks are whole-input prevalidated, but short scalar fallbacks retain the ordinary decoder’s partial-output-on-error behavior.

Source

pub fn decode_url_safe<const PAD: bool>( &self, input: &[u8], output: &mut [u8], ) -> Result<usize, DecodeError>

Decodes strict URL-safe Base64 with the statically admitted backend.

Commits 27, 28, and 29 enable direct SSSE3/SSE4.1, AVX2, AVX-512 VBMI, and little-endian AArch64 NEON execution. Invalid input retains the ordinary strict decoder’s exact diagnostics. Direct SIMD blocks are whole-input prevalidated, but short scalar fallbacks retain the ordinary decoder’s partial-output-on-error behavior.

Trait Implementations§

Source§

impl Debug for StaticBackendToken

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.