pub struct Output {
pub spec: ObjectSpec,
/* private fields */
}Expand description
One instance of output DataObject.
The output can be either empty (as is initially),
set to represent an existing file, set to represent an existing directory, or written
to as a Write. These three are mutually exclusive, set_dir_path and set_file_path
may be used only once, and not before or after get_writer.
This object is thread-safe and the internal state is guarded by a mutex. Calling
get_writer locks this mutex and holds it until the returned guard is dropped.
This means fast (lockless) writes to the Write but you need to make sure your
other threads do not starve or deadlock.
Fields§
§spec: ObjectSpecThe original output description
Implementations§
Source§impl Output
impl Output
Sourcepub fn stage_directory<P: AsRef<Path>>(&mut self, path: P) -> TaskResult<()>
pub fn stage_directory<P: AsRef<Path>>(&mut self, path: P) -> TaskResult<()>
Submit the given directory as the output contents. Moves the directory to the staging area. You should make sure no files in the directory are open after this operation.
Panics if the output was submitted to and on I/O errors. Returns an error if the output is not a directory type.
Sourcepub fn stage_file<P: AsRef<Path>>(&mut self, path: P) -> TaskResult<()>
pub fn stage_file<P: AsRef<Path>>(&mut self, path: P) -> TaskResult<()>
Submit the given file as the output contents. Moves the file to the staging area. You should make sure that the file is not open after this operation.
Panics if the output was submitted or written to and on I/O errors. Returns an error if the output is not a file directory type.
Sourcepub fn stage_input(&mut self, object: &DataInstance) -> TaskResult<()>
pub fn stage_input(&mut self, object: &DataInstance) -> TaskResult<()>
Set the output to a given input data object. No data is copied in this case and the governor is informed of the pass-through. The input must belong to the same task (this is not checked). Not allowed if the output was submitted or written to.
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_content_type(&self) -> String
pub fn get_content_type(&self) -> String
Get the content-type of the object.
Returns the type set in the executor if any, or the type in the spec. Returns “” for directories.
Sourcepub fn set_content_type(&mut self, ctype: impl Into<String>) -> TaskResult<()>
pub fn set_content_type(&mut self, ctype: impl Into<String>) -> TaskResult<()>
Sets the content type of the object.
Returns an error for directories, incompatible content types and if it has been already set.
Sourcepub fn set_user_info(&mut self, key: impl Into<String>, val: UserValue)
pub fn set_user_info(&mut self, key: impl Into<String>, val: UserValue)
Sets the info.user[key] to value.
Any old value is overwriten.
Sourcepub fn make_file_backed(&mut self) -> TaskResult<()>
pub fn make_file_backed(&mut self) -> TaskResult<()>
If the output is empty or backed by memory, it is converted to a file. Does nothing if already backed by a file. Returns an error for staged files and inputs.
Trait Implementations§
Source§impl Write for Output
impl Write for Output
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)