Struct protoflow_blocks::WriteFile

source ·
pub struct WriteFile {
    pub path: InputPort<String>,
    pub input: InputPort<Bytes>,
}
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.txt

Fields§

§path: InputPort<String>

The path to the file to write to.

§input: InputPort<Bytes>

The input message stream.

Implementations§

source§

impl WriteFile

source

pub fn new(path: InputPort<String>, input: InputPort<Bytes>) -> Self

Trait Implementations§

source§

impl Block for WriteFile

source§

fn execute(&mut self, _runtime: &dyn BlockRuntime) -> BlockResult

Executes this block’s computation.
source§

fn prepare(&mut self, _runtime: &dyn BlockRuntime) -> Result<(), BlockError>

Prepares this block for execution. Read more
source§

impl BlockDescriptor for WriteFile

source§

fn inputs(&self) -> Vec<PortDescriptor>

A description of this block’s input ports.
source§

fn outputs(&self) -> Vec<PortDescriptor>

A description of this block’s output ports.
source§

fn name(&self) -> Option<String>

The machine-readable name of this block.
source§

fn label(&self) -> Option<String>

A human-readable label for this block.
source§

impl Clone for WriteFile

source§

fn clone(&self) -> WriteFile

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Definition for WriteFile

source§

impl Element for WriteFile

source§

fn id(&self) -> Option<&str>

The unique element ID, if any.
source§

fn alias_ids(&self) -> Vec<&str>

Various alternative identifiers for this Element.
source§

fn name(&self) -> Option<&str>

The name of the element.
source§

fn short_name(&self) -> Option<&str>

The short name of the element, if any.
source§

fn is_library_element(&self) -> bool

Whether this Element is contained in the ownership tree of a library model.
source§

fn owner(&self) -> Option<&dyn Element>

The owner of this Element, if any.
source§

fn owning_namespace(&self) -> Option<&dyn Namespace>

The Namespace that owns this Element, if any.
source§

fn owning_relationship(&self) -> Option<&dyn Relationship>

The Relationship for which this Element is an owned_related_element, if any.
source§

fn qualified_name(&self) -> Option<QualifiedName>

source§

impl Namespace for WriteFile

source§

fn names_of(&self, _element: &dyn Element) -> Vec<String>

source§

impl OccurrenceDefinition for WriteFile

source§

impl StdioSystem for WriteFile

source§

impl Type for WriteFile

source§

fn is_abstract(&self) -> bool

source§

fn is_sufficient(&self) -> bool

source§

fn is_conjugated(&self) -> bool

source§

fn specializes(&self, _supertype: &Self) -> bool

source§

impl BlockDefinition for WriteFile

source§

impl Class for WriteFile

source§

impl Classifier for WriteFile

source§

impl ItemDefinition for WriteFile

source§

impl PartDefinition for WriteFile

source§

impl Structure for WriteFile

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsBlock for T
where T: Block,

source§

fn as_block(&self) -> &dyn Block

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V