pub enum Output {
Immediate(Immediate),
Stream(OutputStream),
}
Expand description
The Output
enum provides a general interface for outputs of different types.
The Immediate
variant represents data that is immediately available, while the Stream
variant
represents data that may be produced over time.
Variants§
Immediate(Immediate)
Represents immediately available data.
Stream(OutputStream)
Represents data that is produced over time.
Implementations§
Source§impl Output
impl Output
Sourcepub async fn to_immediate(self) -> Result<Immediate, ExecutorError>
pub async fn to_immediate(self) -> Result<Immediate, ExecutorError>
Converts the Output
to its Immediate
form.
If the output is Stream
, it will be consumed and turned into an Immediate
output.
This operation is asynchronous as it may need to wait for all data to be produced in the case of a Stream
.
Sourcepub async fn as_stream(self) -> Result<OutputStream, NotAStreamError>
pub async fn as_stream(self) -> Result<OutputStream, NotAStreamError>
Given that the Output is a stream, return a OutputStream
If the output is Immediate
NotAStreamError will be raised
Sourcepub fn new_stream() -> (UnboundedSender<StreamSegment>, Self)
pub fn new_stream() -> (UnboundedSender<StreamSegment>, Self)
Creates a new Stream
output along with a sender to produce data.
pub fn from_stream<S>(stream: S) -> Self
Sourcepub fn new_immediate(data: Data<String>) -> Self
pub fn new_immediate(data: Data<String>) -> Self
Creates a new Immediate
output from the given data.