pub struct InputBuffer { /* private fields */ }Expand description
Bytes to read, however they were obtained.
Implementations§
Source§impl InputBuffer
impl InputBuffer
Sourcepub fn from_bytes(bytes: Vec<u8>) -> Self
pub fn from_bytes(bytes: Vec<u8>) -> Self
Takes ownership of bytes already in hand.
Sourcepub fn from_owner<T>(owner: T) -> Self
pub fn from_owner<T>(owner: T) -> Self
Retains stable externally owned bytes without copying their payload.
The owner is held for the complete lifetime of this buffer and every clone. This is the adoption path for language-runtime byte objects and existing immutable buffers whose address remains stable.
Sourcepub fn open(path: impl AsRef<Path>, limits: Limits) -> Result<Self, Diagnostic>
pub fn open(path: impl AsRef<Path>, limits: Limits) -> Result<Self, Diagnostic>
Opens and transparently decompresses a bounded local file.
§Errors
Returns a registered resource or limit diagnostic.
Sourcepub fn from_reader(
reader: impl Read,
limits: Limits,
) -> Result<Self, Diagnostic>
pub fn from_reader( reader: impl Read, limits: Limits, ) -> Result<Self, Diagnostic>
Reads a bounded stream and transparently decompresses its bytes.
§Errors
Returns a registered resource or limit diagnostic.
Sourcepub fn with_origin(self, origin: &str) -> Self
pub fn with_origin(self, origin: &str) -> Self
Names where the bytes came from.
Source§impl InputBuffer
impl InputBuffer
Sourcepub fn from_encoded_bytes(
bytes: Vec<u8>,
limits: Limits,
) -> Result<Self, Diagnostic>
pub fn from_encoded_bytes( bytes: Vec<u8>, limits: Limits, ) -> Result<Self, Diagnostic>
Adopts plain bytes or decodes a gzip/Zstandard container within limits.
Plain bytes retain their allocation. Compressed bytes are decoded directly
from the supplied vector; expanded output uses private mapped storage when
mmap is enabled. Self::from_bytes deliberately performs no decoding.
use molframe_core::io::{InputBuffer, Limits};
let bytes = b"data_example\n".to_vec();
let pointer = bytes.as_ptr();
let input = InputBuffer::from_encoded_bytes(bytes, Limits::default())?;
assert_eq!(input.as_bytes().as_ptr(), pointer);§Errors
Invalid containers, unavailable decoders, or exceeded byte/expansion limits.
Trait Implementations§
Source§impl Clone for InputBuffer
impl Clone for InputBuffer
Source§impl Debug for InputBuffer
impl Debug for InputBuffer
Source§impl SourceBytes for InputBuffer
impl SourceBytes for InputBuffer
Auto Trait Implementations§
impl !RefUnwindSafe for InputBuffer
impl !UnwindSafe for InputBuffer
impl Freeze for InputBuffer
impl Send for InputBuffer
impl Sync for InputBuffer
impl Unpin for InputBuffer
impl UnsafeUnpin for InputBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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