SplitStreamWriter

Struct SplitStreamWriter 

Source
pub struct SplitStreamWriter<ObjectID: FsVerityHashValue> {
    repo: Arc<Repository<ObjectID>>,
    inline_content: Vec<u8>,
    writer: Encoder<'static, Vec<u8>>,
    pub sha256: Option<(Sha256, Sha256Digest)>,
}
Expand description

Writer for creating split stream format files with inline content and external object references.

Fields§

§repo: Arc<Repository<ObjectID>>§inline_content: Vec<u8>§writer: Encoder<'static, Vec<u8>>§sha256: Option<(Sha256, Sha256Digest)>

Optional SHA256 hasher and expected digest for validation

Implementations§

Source§

impl<ObjectID: FsVerityHashValue> SplitStreamWriter<ObjectID>

Source

pub fn new( repo: &Arc<Repository<ObjectID>>, refs: Option<DigestMap<ObjectID>>, sha256: Option<Sha256Digest>, ) -> Self

Creates a new split stream writer.

The writer is initialized with optional digest map references and an optional expected SHA256 hash for validation when the stream is finalized.

Source

fn write_fragment( writer: &mut impl Write, size: usize, data: &[u8], ) -> Result<()>

Source

fn flush_inline(&mut self, new_value: Vec<u8>) -> Result<()>

flush any buffered inline data, taking new_value as the new value of the buffer

Source

pub fn write_inline(&mut self, data: &[u8])

really, “add inline content to the buffer” you need to call .flush_inline() later

Source

fn write_reference( &mut self, reference: &ObjectID, padding: Vec<u8>, ) -> Result<()>

write a reference to external data to the stream. If the external data had padding in the stream which is not stored in the object then pass it here as well and it will be stored inline after the reference.

Source

pub fn write_external(&mut self, data: &[u8], padding: Vec<u8>) -> Result<()>

Writes data as an external object reference with optional padding.

The data is stored in the repository and a reference is written to the stream. Any padding bytes are stored inline after the reference.

Source

pub async fn write_external_async( &mut self, data: Vec<u8>, padding: Vec<u8>, ) -> Result<()>

Asynchronously writes data as an external object reference with optional padding.

The data is stored in the repository asynchronously and a reference is written to the stream. Any padding bytes are stored inline after the reference.

Source

pub fn done(self) -> Result<ObjectID>

Finalizes the split stream and returns its object ID.

Flushes any remaining inline content, validates the SHA256 hash if provided, and stores the compressed stream in the repository.

Trait Implementations§

Source§

impl<ObjectID: FsVerityHashValue> Debug for SplitStreamWriter<ObjectID>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<ObjectID> Freeze for SplitStreamWriter<ObjectID>

§

impl<ObjectID> RefUnwindSafe for SplitStreamWriter<ObjectID>
where ObjectID: RefUnwindSafe,

§

impl<ObjectID> Send for SplitStreamWriter<ObjectID>

§

impl<ObjectID> Sync for SplitStreamWriter<ObjectID>

§

impl<ObjectID> Unpin for SplitStreamWriter<ObjectID>

§

impl<ObjectID> !UnwindSafe for SplitStreamWriter<ObjectID>

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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V