PlaceholderDataBox

Struct PlaceholderDataBox 

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

A PlaceholderDataBox allows you to reserve space in a JUMBF data structure for content that will be filled in after the overall JUMBF data structure is created.

You can specify a data size to reserve. When the initial JUMBF data structure is created, the box will be zero-filled to the specified size. Later, you can call replace_payload() to replace that reserved space with new content.

Implementations§

Source§

impl PlaceholderDataBox

Source

pub fn new(tbox: BoxType, size: usize) -> Self

Create a new placeholder data box that will reserve size bytes.

The box will be given the JUMBF box type specified by tbox.

Source

pub fn offset(&self) -> Option<u64>

Return the offset in the stream where the payload can be written.

Will return None before the superbox’s write_jumbf() method is called.

Source

pub fn replace_payload( &self, to_stream: &mut dyn WriteAndSeek, payload: &[u8], ) -> Result<()>

Replace the zero-filled placeholder content with actual content.

An error will be returned if payload is larger than the placeholder size specified when this PlaceholderDataBox was created.

Assuming the placeholder is not larger than the initial reservation, this method will seek the stream to offset() and write the new payload at that location.

Trait Implementations§

Source§

impl ToBox for PlaceholderDataBox

Source§

fn box_type(&self) -> BoxType

Specifies the type of information which will be provided by the write_payload() method. Read more
Source§

fn payload_size(&self) -> Result<usize>

Returns the size of the payload which will be provided by the write_payload() method. Read more
Source§

fn write_payload(&self, to_stream: &mut dyn WriteAndSeek) -> Result<()>

Write the payload for this box to the JUMBF stream. 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.