pub struct DataItem {
pub label: Label,
pub media_type: MediaType,
pub source_name: String,
pub extension: String,
pub metadata: HashMap<String, String>,
/* private fields */
}Expand description
A single data sample flowing through the dataset pipeline.
Fields§
§label: LabelDataset label.
media_type: MediaTypeMedia kind for the sample.
source_name: StringLogical source name.
extension: StringFile extension including the leading dot.
metadata: HashMap<String, String>String metadata attached to the sample.
Implementations§
Source§impl DataItem
impl DataItem
Sourcepub fn new(
bytes: Vec<u8>,
label: Label,
media_type: MediaType,
source_name: impl Into<String>,
) -> AppResult<Self>
pub fn new( bytes: Vec<u8>, label: Label, media_type: MediaType, source_name: impl Into<String>, ) -> AppResult<Self>
Create an item from bounded in-memory bytes.
Sourcepub fn new_bytes(
bytes: Vec<u8>,
label: Label,
media_type: MediaType,
source_name: impl Into<String>,
) -> AppResult<Self>
pub fn new_bytes( bytes: Vec<u8>, label: Label, media_type: MediaType, source_name: impl Into<String>, ) -> AppResult<Self>
Create an item from bounded in-memory bytes.
Sourcepub fn new_bytes_with_limits(
bytes: Vec<u8>,
label: Label,
media_type: MediaType,
source_name: impl Into<String>,
limits: &DatasetLimits,
) -> AppResult<Self>
pub fn new_bytes_with_limits( bytes: Vec<u8>, label: Label, media_type: MediaType, source_name: impl Into<String>, limits: &DatasetLimits, ) -> AppResult<Self>
Create an item from bounded in-memory bytes with explicit limits.
Sourcepub fn new_file(
path: impl Into<PathBuf>,
label: Label,
media_type: MediaType,
source_name: impl Into<String>,
) -> Self
pub fn new_file( path: impl Into<PathBuf>, label: Label, media_type: MediaType, source_name: impl Into<String>, ) -> Self
Create an item from a file path for streaming large payloads.
Sourcepub fn payload(&self) -> &DataPayload
pub fn payload(&self) -> &DataPayload
Borrow the item payload.
Sourcepub fn try_with_payload(
self,
payload: DataPayload,
limits: &DatasetLimits,
) -> AppResult<Self>
pub fn try_with_payload( self, payload: DataPayload, limits: &DatasetLimits, ) -> AppResult<Self>
Replace the payload after validating it against explicit limits.
Sourcepub fn source_offset(&self) -> Option<usize>
pub fn source_offset(&self) -> Option<usize>
Return the source-provided resume cursor after this item, if available.
Sourcepub fn with_source_offset(self, offset: usize) -> Self
pub fn with_source_offset(self, offset: usize) -> Self
Attach a source-provided resume cursor.
Sourcepub fn with_extension(self, ext: impl Into<String>) -> Self
pub fn with_extension(self, ext: impl Into<String>) -> Self
Set the output extension.
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Attach string metadata.
Sourcepub fn validate(&self, limits: &DatasetLimits) -> AppResult<()>
pub fn validate(&self, limits: &DatasetLimits) -> AppResult<()>
Validate the item against configured limits and path safety rules.
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 this item to path using the configured payload limits.
Trait Implementations§
Source§impl DatasetItem for DataItem
impl DatasetItem for DataItem
Source§fn label(&self) -> Label
fn label(&self) -> Label
Label::Real.Source§fn source_offset(&self) -> Option<usize>
fn source_offset(&self) -> Option<usize>
Source§impl ItemSink<DataItem> for LocalBlobSink
impl ItemSink<DataItem> for LocalBlobSink
Source§fn prepare<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = AppResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn prepare<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = AppResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl Freeze for DataItem
impl RefUnwindSafe for DataItem
impl Send for DataItem
impl Sync for DataItem
impl Unpin for DataItem
impl UnsafeUnpin for DataItem
impl UnwindSafe for DataItem
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
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>
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