pub struct DataPayload { /* private fields */ }Expand description
Payload for a single dataset item.
In-memory payloads can only be constructed through checked constructors so
large datasets do not accidentally bypass DatasetLimits.
Implementations§
Source§impl DataPayload
impl DataPayload
Sourcepub fn bytes(bytes: Vec<u8>, limits: &DatasetLimits) -> AppResult<Self>
pub fn bytes(bytes: Vec<u8>, limits: &DatasetLimits) -> AppResult<Self>
Create a bounded in-memory payload with explicit limits.
Sourcepub fn bytes_default(bytes: Vec<u8>) -> AppResult<Self>
pub fn bytes_default(bytes: Vec<u8>) -> AppResult<Self>
Create a bounded in-memory payload using DatasetLimits::default.
Sourcepub fn file(path: impl Into<PathBuf>) -> Self
pub fn file(path: impl Into<PathBuf>) -> Self
Create a file-backed payload for streaming large data.
Sourcepub fn as_file(&self) -> Option<&Path>
pub fn as_file(&self) -> Option<&Path>
Borrow the file path when this is a file-backed payload.
Sourcepub fn len(&self) -> AppResult<u64>
pub fn len(&self) -> AppResult<u64>
Return the payload size in bytes when it can be determined.
Sourcepub fn read_bytes_bounded(&self, limits: &DatasetLimits) -> AppResult<Vec<u8>>
pub fn read_bytes_bounded(&self, limits: &DatasetLimits) -> AppResult<Vec<u8>>
Read a payload into memory only if it is within configured bounds.
Sourcepub fn write_to_path(
&self,
path: &Path,
limits: &DatasetLimits,
) -> AppResult<u64>
pub fn write_to_path( &self, path: &Path, limits: &DatasetLimits, ) -> AppResult<u64>
Write the payload to path, streaming file payloads without materializing them.
Trait Implementations§
Source§impl Clone for DataPayload
impl Clone for DataPayload
Source§fn clone(&self) -> DataPayload
fn clone(&self) -> DataPayload
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DataPayload
impl RefUnwindSafe for DataPayload
impl Send for DataPayload
impl Sync for DataPayload
impl Unpin for DataPayload
impl UnsafeUnpin for DataPayload
impl UnwindSafe for DataPayload
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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