pub struct ReadFile {
pub path: InputPort<String>,
pub output: OutputPort<Bytes>,
}Expand description
A block that reads bytes from the contents of a file.
§Block Diagram
block-beta
columns 4
Config space:3
space:4
space:4
ReadFile space:2 Sink
Config-- "path" -->ReadFile
ReadFile-- "output" -->Sink
classDef block height:48px,padding:8px;
classDef hidden visibility:none;
class ReadFile block
class Config hidden
class Sink hidden
§Sequence Diagram
sequenceDiagram
autonumber
participant BlockA as Another block
participant ReadFile.path as ReadFile.path port
participant ReadFile as ReadFile block
participant ReadFile.output as ReadFile.output port
participant BlockB as Another block
BlockA-->>ReadFile: Connect
BlockA->>ReadFile: Message (e.g. "/tmp/file.txt")
ReadFile-->>ReadFile.path: Close
ReadFile-->>BlockA: Disconnect
ReadFile-->>BlockB: Connect
loop ReadFile process
ReadFile->>ReadFile: Read bytes from the file
ReadFile->>BlockB: Message (Bytes)
end
ReadFile-->>ReadFile.output: Close
ReadFile-->>BlockB: Disconnect
§Examples
§Using the block in a system
System::build(|s| {
// TODO
});§Running the block via the CLI
$ protoflow execute ReadFile path=/tmp/file.txtFields§
§path: InputPort<String>The path to the file to read from.
output: OutputPort<Bytes>The output message stream.
Implementations§
Trait Implementations§
Source§impl Block for ReadFile
impl Block for ReadFile
Source§fn execute(&mut self, _runtime: &dyn BlockRuntime) -> BlockResult
fn execute(&mut self, _runtime: &dyn BlockRuntime) -> BlockResult
Executes this block’s computation.
Source§fn prepare(&mut self, _runtime: &dyn BlockRuntime) -> Result<(), BlockError>
fn prepare(&mut self, _runtime: &dyn BlockRuntime) -> Result<(), BlockError>
Prepares this block for execution. Read more
Source§impl BlockDescriptor for ReadFile
impl BlockDescriptor for ReadFile
Source§fn inputs(&self) -> Vec<PortDescriptor>
fn inputs(&self) -> Vec<PortDescriptor>
A description of this block’s input ports.
Source§fn outputs(&self) -> Vec<PortDescriptor>
fn outputs(&self) -> Vec<PortDescriptor>
A description of this block’s output ports.
Source§fn parameters(&self) -> Vec<ParameterDescriptor>
fn parameters(&self) -> Vec<ParameterDescriptor>
A description of this block’s parameters.
Source§fn ports(&self) -> Vec<PortDescriptor>
fn ports(&self) -> Vec<PortDescriptor>
A description of this block’s I/O ports.
Source§impl MaybeLabeled for ReadFile
impl MaybeLabeled for ReadFile
Source§impl MaybeNamed for ReadFile
impl MaybeNamed for ReadFile
Source§impl StdioSystem for ReadFile
impl StdioSystem for ReadFile
fn build_system(config: StdioConfig) -> Result<System, StdioError>
Auto Trait Implementations§
impl Freeze for ReadFile
impl !RefUnwindSafe for ReadFile
impl Send for ReadFile
impl Sync for ReadFile
impl Unpin for ReadFile
impl !UnwindSafe for ReadFile
Blanket Implementations§
Source§impl<T> AsBlockDescriptor for Twhere
T: BlockDescriptor,
impl<T> AsBlockDescriptor for Twhere
T: BlockDescriptor,
fn as_block_descriptor(&self) -> &dyn BlockDescriptor
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more