pub struct ReadDir {
pub path: InputPort<String>,
pub output: OutputPort<String>,
}Expand description
A block that reads file names from a file system directory.
§Block Diagram
block-beta
columns 4
Config space:3
space:4
space:4
ReadDir space:2 Sink
Config-- "path" -->ReadDir
ReadDir-- "output" -->Sink
classDef block height:48px,padding:8px;
classDef hidden visibility:none;
class ReadDir block
class Config hidden
class Sink hidden
§Sequence Diagram
sequenceDiagram
autonumber
participant BlockA as Another block
participant ReadDir.path as ReadDir.path port
participant ReadDir as ReadDir block
participant ReadDir.output as ReadDir.output port
participant BlockB as Another block
BlockA-->>ReadDir: Connect
BlockA->>ReadDir: Message (e.g. "/tmp")
ReadDir-->>ReadDir.path: Close
ReadDir-->>BlockA: Disconnect
ReadDir-->>BlockB: Connect
loop ReadDir process
ReadDir->>ReadDir: Read directory entries
ReadDir->>BlockB: Message (e.g. "/tmp/file.txt")
end
ReadDir-->>ReadDir.output: Close
ReadDir-->>BlockB: Disconnect
§Examples
§Using the block in a system
System::build(|s| {
let path_param = s.const_string("/tmp");
let dir_reader = s.read_dir();
let line_encoder = s.encode_lines();
let stdout = s.write_stdout();
s.connect(&path_param.output, &dir_reader.path);
s.connect(&dir_reader.output, &line_encoder.input);
s.connect(&line_encoder.output, &stdout.input);
});§Running the block via the CLI
$ protoflow execute ReadDir path=/tmpFields§
§path: InputPort<String>The path to the directory to read.
output: OutputPort<String>The output message stream.
Implementations§
Trait Implementations§
Source§impl Block for ReadDir
impl Block for ReadDir
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 ReadDir
impl BlockDescriptor for ReadDir
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 ReadDir
impl MaybeLabeled for ReadDir
Source§impl MaybeNamed for ReadDir
impl MaybeNamed for ReadDir
Source§impl StdioSystem for ReadDir
impl StdioSystem for ReadDir
fn build_system(config: StdioConfig) -> Result<System, StdioError>
Auto Trait Implementations§
impl Freeze for ReadDir
impl !RefUnwindSafe for ReadDir
impl Send for ReadDir
impl Sync for ReadDir
impl Unpin for ReadDir
impl !UnwindSafe for ReadDir
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