native_neural_network 0.3.1

Lib no_std Rust for native neural network (.rnn)
Documentation
from __future__ import annotations

from dataclasses import dataclass

try:
    from .ffi import BenchmarkRecord, BenchmarkView, FfiLibrary
except ImportError:
    from ffi import BenchmarkRecord, BenchmarkView, FfiLibrary


@dataclass
class BenchmarkBlob:
    ffi: FfiLibrary

    @classmethod
    def create(cls, ffi: FfiLibrary | None = None) -> "BenchmarkBlob":
        return cls(ffi=ffi or FfiLibrary())

    def encode(self, record: BenchmarkRecord) -> bytes:
        return self.ffi.encode_benchmark_blob(record)

    def decode(self, blob: bytes) -> BenchmarkView:
        return self.ffi.decode_benchmark_blob(blob)