Struct rain_task::Output [−][src]
pub struct Output { pub spec: ObjectSpec, // some fields omitted }
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: ObjectSpec
The original output description
Methods
impl Output
[src]
impl Output
pub fn stage_directory<P: AsRef<Path>>(&mut self, path: P) -> TaskResult<()>
[src]
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.
pub fn stage_file<P: AsRef<Path>>(&mut self, path: P) -> TaskResult<()>
[src]
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.
pub fn stage_input(&mut self, object: &DataInstance) -> TaskResult<()>
[src]
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.
pub fn check_directory(&self) -> TaskResult<()>
[src]
pub fn check_directory(&self) -> TaskResult<()>
A shorthand to check that the input is a directory.
Returns Err(TaskError)
if not a directory.
pub fn check_blob(&self) -> TaskResult<()>
[src]
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.
pub fn get_content_type(&self) -> String
[src]
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.
pub fn set_content_type(
&mut self,
ctype: impl Into<String>
) -> TaskResult<()>
[src]
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.
pub fn set_user_info(
&mut self,
key: impl Into<String>,
val: UserValue
)
[src]
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.
pub fn make_file_backed(&mut self) -> TaskResult<()>
[src]
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
impl Debug for Output
[src]
impl Debug for Output
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Display for Output
[src]
impl Display for Output
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Write for Output
[src]
impl Write for Output
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<()>
[src]
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
Writes a formatted string into this writer, returning any error encountered. Read more
ⓘImportant traits for &'a mut Rfn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
Creates a "by reference" adaptor for this instance of Write
. Read more