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
impl DataInstance
Sourcepub fn get_bytes<'a>(&'a self) -> TaskResult<&'a [u8]>
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.
Sourcepub fn get_path(&self) -> PathBuf
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.
Sourcepub fn check_directory(&self) -> TaskResult<()>
pub fn check_directory(&self) -> TaskResult<()>
A shorthand to check that the input is a directory.
Returns Err(TaskError)
if not a directory.
Sourcepub fn check_blob(&self) -> TaskResult<()>
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.
Sourcepub fn get_str<'a>(&'a self) -> TaskResult<&'a str>
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.
Sourcepub fn check_content_type(&self, _ctype: &str) -> TaskResult<()>
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.
Sourcepub fn get_content_type(&self) -> String
pub fn get_content_type(&self) -> String
Get the content-type of the object.
Returns “” for directories.