Skip to main content

BlobHeader

Struct BlobHeader 

Source
pub struct BlobHeader {
Show 14 fields pub size: u64, pub required_mask: u64, pub planes_bytes: u64, pub storage_kind: u32, pub pid: u32, pub fence_fd: i32, pub dtype: u32, pub quant_axis: i32, pub ndim: u32, pub plane_count: u32, pub quant_scales_len: u32, pub quant_zero_points_len: u32, pub strings_bytes: u32, pub strides_len: u32,
}
Expand description

The blob’s fixed header. See the module docs for the byte layout.

Field order here mirrors the byte layout so the two can be read side by side, but this struct is never cast to or from bytes — see Self::write_to and parse_header, which go field by field in explicit little-endian.

Fields§

§size: u64

Total bytes of this blob, header included. The size prefix that makes the format append-only: an older consumer reads the prefix it knows and skips to size.

§required_mask: u64

Bits describing additions that change interpretation rather than adding information. Any bit a consumer does not recognise means refuse.

§planes_bytes: u64

Byte length of the planes region.

§storage_kind: u32

Backing store for the whole tensor; the shared TensorMemory code.

§pid: u32

Producer pid, for pidfd_open/pidfd_getfd and, on Windows, for OpenProcess(PROCESS_DUP_HANDLE). Zero when all planes are inlined, where there is no handle to reopen.

Trust boundary. This value and the handle values beside it come out of the blob, so a hostile one makes an importer probe a pid it chose and a handle slot in that process. That is the whole of what it buys: the import asks for PROCESS_DUP_HANDLE alone, and hands the duplicate only to OpenSharedResource1 / OpenSharedFence, which refuse anything that is not a shareable D3D11 object. Nothing here makes a blob safe to accept from an untrusted peer – import blobs from peers you would already hand a texture to.

§fence_fd: i32

Acquire fence, or -1 for none. Per-tensor, never per-plane.

§dtype: u32

Element type; the shared DType code.

§quant_axis: i32

Per-channel quantization axis; -1 per-tensor, -2 none.

§ndim: u32

Number of dimensions in the addressing grid.

§plane_count: u32

Number of plane records in the planes region.

§quant_scales_len: u32

Number of f32 quantization scales.

§quant_zero_points_len: u32

Number of i32 zero points; zero means symmetric.

§strings_bytes: u32

Byte length of the five-string region.

§strides_len: u32

Number of stride entries: ndim, or 0 meaning densely packed C-order.

Carried rather than assumed — an empty stride array is a distinct value per Tensor.msg, not an absent one, and flattening the two would break the reference-mode round-trip identity.

Implementations§

Source§

impl BlobHeader

Source

pub fn empty() -> Self

An all-zero header, for tests and for .. update syntax.

Source

pub fn write_to(&self, buf: &mut [u8])

Serialize into the first HEADER_LEN bytes of buf.

§Panics

If buf is shorter than HEADER_LEN.

Trait Implementations§

Source§

impl Clone for BlobHeader

Source§

fn clone(&self) -> BlobHeader

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for BlobHeader

Source§

impl Debug for BlobHeader

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for BlobHeader

Source§

fn default() -> BlobHeader

Returns the “default value” for a type. Read more
Source§

impl Eq for BlobHeader

Source§

impl PartialEq for BlobHeader

Source§

fn eq(&self, other: &BlobHeader) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BlobHeader

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more