Skip to main content

DataItem

Struct DataItem 

Source
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: Label

Dataset label.

§media_type: MediaType

Media kind for the sample.

§source_name: String

Logical source name.

§extension: String

File extension including the leading dot.

§metadata: HashMap<String, String>

String metadata attached to the sample.

Implementations§

Source§

impl DataItem

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn payload(&self) -> &DataPayload

Borrow the item payload.

Source

pub fn try_with_payload( self, payload: DataPayload, limits: &DatasetLimits, ) -> AppResult<Self>

Replace the payload after validating it against explicit limits.

Source

pub fn source_offset(&self) -> Option<usize>

Return the source-provided resume cursor after this item, if available.

Source

pub fn with_source_offset(self, offset: usize) -> Self

Attach a source-provided resume cursor.

Source

pub fn with_extension(self, ext: impl Into<String>) -> Self

Set the output extension.

Source

pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Attach string metadata.

Source

pub fn validate(&self, limits: &DatasetLimits) -> AppResult<()>

Validate the item against configured limits and path safety rules.

Source

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 Clone for DataItem

Source§

fn clone(&self) -> DataItem

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl DatasetItem for DataItem

Source§

fn label(&self) -> Label

Classification label used to route and count the item. Defaults to Label::Real.
Source§

fn source_offset(&self) -> Option<usize>

Source-provided resume cursor observed after this item, if any.
Source§

impl Debug for DataItem

Source§

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

Formats the value using the given formatter. Read more
Source§

impl ItemSink<DataItem> for LocalBlobSink

Source§

fn name(&self) -> &str

Stable sink name.
Source§

fn prepare<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = AppResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Prepare the destination before any item is written (create directories, seed counters).
Source§

fn write<'life0, 'async_trait>( &'life0 self, item: DataItem, ) -> Pin<Box<dyn Future<Output = AppResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Materialize a single collected item.
Source§

fn finish<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = AppResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Flush and finalize the destination after the last item is written.
Source§

impl Transform<DataItem, DataItem> for ResizeTransform

Available on crate feature image-transform only.
Source§

fn name(&self) -> &str

Stable transform name.
Source§

fn apply( &self, item: DataItem, limits: &DatasetLimits, ) -> AppResult<Option<DataItem>>

Apply the transform, returning Ok(None) when the item is filtered out.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more