Struct protoflow_blocks::ReadDir
source · 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=/tmp
Fields§
§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§impl Definition for ReadDir
impl Definition for ReadDir
fn is_variation(&self) -> bool
source§impl Element for ReadDir
impl Element for ReadDir
source§fn short_name(&self) -> Option<&str>
fn short_name(&self) -> Option<&str>
The short name of the element, if any.
source§fn is_library_element(&self) -> bool
fn is_library_element(&self) -> bool
Whether this
Element is contained in the ownership tree of
a library model.source§fn owning_namespace(&self) -> Option<&dyn Namespace>
fn owning_namespace(&self) -> Option<&dyn Namespace>
source§fn owning_relationship(&self) -> Option<&dyn Relationship>
fn owning_relationship(&self) -> Option<&dyn Relationship>
fn qualified_name(&self) -> Option<QualifiedName>
source§impl OccurrenceDefinition for ReadDir
impl OccurrenceDefinition for ReadDir
fn is_individual(&self) -> bool
source§impl StdioSystem for ReadDir
impl StdioSystem for ReadDir
fn build_system(config: StdioConfig) -> Result<System, StdioError>
source§impl Type for ReadDir
impl Type for ReadDir
fn is_abstract(&self) -> bool
fn is_sufficient(&self) -> bool
fn is_conjugated(&self) -> bool
fn specializes(&self, _supertype: &Self) -> bool
impl BlockDefinition for ReadDir
impl Class for ReadDir
impl Classifier for ReadDir
impl ItemDefinition for ReadDir
impl PartDefinition for ReadDir
impl Structure for ReadDir
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> 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)