Struct protoflow_blocks::ReadFile
source · 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.txt
Fields§
§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§impl Definition for ReadFile
impl Definition for ReadFile
fn is_variation(&self) -> bool
source§impl Element for ReadFile
impl Element for ReadFile
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 ReadFile
impl OccurrenceDefinition for ReadFile
fn is_individual(&self) -> bool
source§impl StdioSystem for ReadFile
impl StdioSystem for ReadFile
fn build_system(_config: StdioConfig) -> Result<System, StdioError>
source§impl Type for ReadFile
impl Type for ReadFile
fn is_abstract(&self) -> bool
fn is_sufficient(&self) -> bool
fn is_conjugated(&self) -> bool
fn specializes(&self, _supertype: &Self) -> bool
impl BlockDefinition for ReadFile
impl Class for ReadFile
impl Classifier for ReadFile
impl ItemDefinition for ReadFile
impl PartDefinition for ReadFile
impl Structure for ReadFile
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> 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)