Struct protoflow_blocks::ReadEnv
source · pub struct ReadEnv<T: Message + FromStr = String> {
pub name: InputPort<String>,
pub output: OutputPort<T>,
}Expand description
A block that reads the value of an environment variable.
§Block Diagram
block-beta
columns 4
Config space:3
space:4
space:4
ReadEnv space:2 Sink
Config-- "name" -->ReadEnv
ReadEnv-- "output" -->Sink
classDef block height:48px,padding:8px;
classDef hidden visibility:none;
class ReadEnv block
class Config hidden
class Sink hidden
§Sequence Diagram
sequenceDiagram
autonumber
participant BlockA as Another block
participant ReadEnv.name as ReadEnv.name port
participant ReadEnv as ReadEnv block
participant ReadEnv.output as ReadEnv.output port
participant BlockB as Another block
BlockA-->>ReadEnv: Connect
BlockA->>ReadEnv: Message (e.g. "TERM")
ReadEnv-->>ReadEnv.name: Close
ReadEnv-->>BlockA: Disconnect
ReadEnv-->>BlockB: Connect
ReadEnv->>ReadEnv: Read environment variable
ReadEnv->>BlockB: Message (e.g. "xterm-256color")
ReadEnv-->>ReadEnv.output: Close
ReadEnv-->>BlockB: Disconnect
§Examples
§Using the block in a system
System::build(|s| {
let name_param = s.const_string("TERM");
let env_reader = s.read_env();
let line_encoder = s.encode_lines();
let stdout = s.write_stdout();
s.connect(&name_param.output, &env_reader.name);
s.connect(&env_reader.output, &line_encoder.input);
s.connect(&line_encoder.output, &stdout.input);
});§Running the block via the CLI
$ protoflow execute ReadEnv name=TERM
Fields§
§name: InputPort<String>The name of the environment variable to read.
output: OutputPort<T>The output message stream.
Implementations§
Trait Implementations§
source§impl<T: Message + FromStr> Block for ReadEnv<T>
impl<T: Message + FromStr> Block for ReadEnv<T>
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<T: Message + FromStr> BlockDescriptor for ReadEnv<T>
impl<T: Message + FromStr> BlockDescriptor for ReadEnv<T>
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<T: Message + FromStr> Definition for ReadEnv<T>
impl<T: Message + FromStr> Definition for ReadEnv<T>
fn is_variation(&self) -> bool
source§impl<T: Message + FromStr> Element for ReadEnv<T>
impl<T: Message + FromStr> Element for ReadEnv<T>
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<T: Message + FromStr> OccurrenceDefinition for ReadEnv<T>
impl<T: Message + FromStr> OccurrenceDefinition for ReadEnv<T>
fn is_individual(&self) -> bool
source§impl<T: Message + FromStr> StdioSystem for ReadEnv<T>
impl<T: Message + FromStr> StdioSystem for ReadEnv<T>
fn build_system(config: StdioConfig) -> Result<System, StdioError>
source§impl<T: Message + FromStr> Type for ReadEnv<T>
impl<T: Message + FromStr> Type for ReadEnv<T>
fn is_abstract(&self) -> bool
fn is_sufficient(&self) -> bool
fn is_conjugated(&self) -> bool
fn specializes(&self, _supertype: &Self) -> bool
impl<T: Message + FromStr> BlockDefinition for ReadEnv<T>
impl<T: Message + FromStr> Class for ReadEnv<T>
impl<T: Message + FromStr> Classifier for ReadEnv<T>
impl<T: Message + FromStr> ItemDefinition for ReadEnv<T>
impl<T: Message + FromStr> PartDefinition for ReadEnv<T>
impl<T: Message + FromStr> Structure for ReadEnv<T>
Auto Trait Implementations§
impl<T> Freeze for ReadEnv<T>
impl<T = String> !RefUnwindSafe for ReadEnv<T>
impl<T> Send for ReadEnv<T>
impl<T> Sync for ReadEnv<T>
impl<T> Unpin for ReadEnv<T>where
T: Unpin,
impl<T = String> !UnwindSafe for ReadEnv<T>
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)