Skip to main content

EmbeddedBundle

Struct EmbeddedBundle 

Source
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

Source

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.

Source

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.

Source

pub fn metadata(&self) -> &[u8]

The opaque metadata blob, a JSON manifest when written by export.

Source

pub fn manifest(&self) -> Result<BundleManifest, BundleError>

The bundle manifest, parsed from metadata and validated against the schema this build understands.

The flat format keeps the manifest out of the read path on purpose, so it is checked here rather than at open: a bundle whose manifest this build can’t read still serves its entries.

Source

pub fn len(&self) -> usize

How many entries the bundle holds, across all namespaces.

Source

pub fn is_empty(&self) -> bool

Whether the bundle holds no entries at all.

Source

pub fn summary(&self) -> Vec<NamespaceSummary>

Entry count and total size per namespace, for reporting.

Trait Implementations§

Source§

impl Bundle for EmbeddedBundle

Source§

fn get(&self, namespace: &str, key: &[u8]) -> Option<Bytes>

The value stored under key in namespace.
Source§

fn scan(&self, namespace: &str, visit: &mut dyn FnMut(&[u8], &[u8]))

Visits every entry of namespace.
Source§

fn namespaces(&self) -> Vec<String>

Every namespace the bundle holds entries for.
Source§

fn describe(&self) -> String

Human-readable origin for log messages.
Source§

impl Debug for EmbeddedBundle

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.