pub struct WriteFile {
pub path: InputPort<String>,
pub input: InputPort<Bytes>,
pub flags: WriteFlags,
}Expand description
A block that writes or appends bytes to the contents of a file.
§Block Diagram
block-beta
columns 4
space:3 Config
space:4
space:4
Source space:2 WriteFile
Config-- "path" -->WriteFile
Source-- "input" -->WriteFile
classDef block height:48px,padding:8px;
classDef hidden visibility:none;
class WriteFile block
class Config hidden
class Source hidden
§Sequence Diagram
sequenceDiagram
autonumber
participant BlockA as Another block
participant WriteFile.path as WriteFile.path port
participant WriteFile as WriteFile block
participant WriteFile.input as WriteFile.input port
participant BlockB as Another block
BlockA-->>WriteFile: Connect
BlockA->>WriteFile: Message (e.g. "/tmp/file.txt")
WriteFile-->>WriteFile.path: Close
WriteFile-->>BlockA: Disconnect
BlockB-->>WriteFile: Connect
loop WriteFile process
BlockB->>WriteFile: Message (Bytes)
WriteFile->>WriteFile: Write bytes to the file
end
BlockB-->>WriteFile: Disconnect
WriteFile-->>WriteFile.input: Close
§Examples
§Using the block in a system
System::build(|s| {
// TODO
});§Running the block via the CLI
$ protoflow execute WriteFile path=/tmp/file.txtFields§
§path: InputPort<String>The path to the file to write to.
input: InputPort<Bytes>The input message stream.
flags: WriteFlagsImplementations§
Source§impl WriteFile
impl WriteFile
pub fn new(path: InputPort<String>, input: InputPort<Bytes>) -> Self
pub fn with_params( path: InputPort<String>, input: InputPort<Bytes>, flags: Option<WriteFlags>, ) -> Self
pub fn with_system(system: &System, flags: Option<WriteFlags>) -> Self
pub fn with_flags(self, flags: WriteFlags) -> Self
Trait Implementations§
Source§impl Block for WriteFile
impl Block for WriteFile
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 WriteFile
impl BlockDescriptor for WriteFile
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 WriteFile
impl MaybeLabeled for WriteFile
Source§impl MaybeNamed for WriteFile
impl MaybeNamed for WriteFile
Source§impl StdioSystem for WriteFile
impl StdioSystem for WriteFile
fn build_system(config: StdioConfig) -> Result<System, StdioError>
Auto Trait Implementations§
impl Freeze for WriteFile
impl !RefUnwindSafe for WriteFile
impl Send for WriteFile
impl Sync for WriteFile
impl Unpin for WriteFile
impl !UnwindSafe for WriteFile
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