Struct DataInstance

Source
pub struct DataInstance {
    pub spec: ObjectSpec,
    pub info: ObjectInfo,
    /* private fields */
}
Expand description

One instance of input DataObject.

Fields§

§spec: ObjectSpec§info: ObjectInfo

Implementations§

Source§

impl DataInstance

Source

pub fn get_bytes<'a>(&'a self) -> TaskResult<&'a [u8]>

Get all the input bytes. In case the input is a file, it is mmap-ed the first time this is called.

Note that every invocation locks the input mutex.

Panics on any I/O error. Returns an error if the input is a directory.

Source

pub fn get_path(&self) -> PathBuf

Get the path for the input file. If the input was memory backed, this will write the file to the filesystem the first time this is called. Note that even when written to disk, the data is also still kept in memory.

Note that every invocation locks the input mutex.

Source

pub fn check_directory(&self) -> TaskResult<()>

A shorthand to check that the input is a directory.

Returns Err(TaskError) if not a directory.

Source

pub fn check_blob(&self) -> TaskResult<()>

A shorthand to check that the input is a file or data blob.

Returns Err(TaskError) if not a blob.

Source

pub fn get_str<'a>(&'a self) -> TaskResult<&'a str>

Panics on any I/O error.

Returns an error if the input is a directory or non-text content-type, or if the input is not valud utf-8. Any other encoding needs to be decoded manually.

Note: checks for valid utf-8 on every call.

Source

pub fn check_content_type(&self, _ctype: &str) -> TaskResult<()>

Check the input content-type.

Return Ok if the actual type is a subtype or supertype of the given type.

Source

pub fn get_content_type(&self) -> String

Get the content-type of the object.

Returns “” for directories.

Trait Implementations§

Source§

impl Debug for DataInstance

Source§

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

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

impl Display for DataInstance

Source§

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

Formats the value using the given formatter. Read more

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<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.