pub struct EmbeddedBundle { /* private fields */ }Expand description
A bundle held as one blob of bytes, embedded in the binary with
include_bytes! or fetched at runtime.
This is the format for targets without a file system. The blob is held as
shared Bytes, so a lookup hands back a zero-copy window into it rather
than a copy: serving a compiled kernel costs a reference count, whatever
its size.
Ignored rather than run: the bundle file is produced by
cargo xtask bundle export --format flat, so there is none to include here.
use cubecl_environment::bundle::{self, EmbeddedBundle};
static BUNDLE: &[u8] = include_bytes!("../bundles/h100.ccb");
let bundle = EmbeddedBundle::from_static(BUNDLE).expect("valid bundle");
bundle::import(&bundle);Implementations§
Source§impl EmbeddedBundle
impl EmbeddedBundle
Sourcepub fn open(bytes: Bytes) -> Result<Self, EmbeddedBundleError>
pub fn open(bytes: Bytes) -> Result<Self, EmbeddedBundleError>
Reads a flat bundle, validating it once so that later lookups can’t fail.
The blob is shared on the way in so that lookups can return zero-copy windows into it.
Sourcepub fn from_static(blob: &'static [u8]) -> Result<Self, EmbeddedBundleError>
pub fn from_static(blob: &'static [u8]) -> Result<Self, EmbeddedBundleError>
Reads a flat bundle embedded in the binary with include_bytes!.
With the shared-bytes feature the static blob is adopted as is, so
the bundle occupies no heap at all. Without it, the bytes are copied
once at startup.
Sourcepub fn metadata(&self) -> &[u8] ⓘ
pub fn metadata(&self) -> &[u8] ⓘ
The opaque metadata blob, a JSON manifest when written by
export.
Sourcepub fn manifest(&self) -> Result<BundleManifest, BundleError>
pub fn manifest(&self) -> Result<BundleManifest, BundleError>
Sourcepub fn summary(&self) -> Vec<NamespaceSummary>
pub fn summary(&self) -> Vec<NamespaceSummary>
Entry count and total size per namespace, for reporting.
Trait Implementations§
Source§impl Bundle for EmbeddedBundle
impl Bundle for EmbeddedBundle
Source§fn get(&self, namespace: &str, key: &[u8]) -> Option<Bytes>
fn get(&self, namespace: &str, key: &[u8]) -> Option<Bytes>
key in namespace.Source§fn scan(&self, namespace: &str, visit: &mut dyn FnMut(&[u8], &[u8]))
fn scan(&self, namespace: &str, visit: &mut dyn FnMut(&[u8], &[u8]))
namespace.