pub struct DecodeJson {
pub input: InputPort<Bytes>,
pub output: OutputPort<Value>,
}Expand description
A block that decodes a JSON format message from a byte stream.
§Block Diagram
block-beta
columns 7
Source space:2 DecodeJSON space:2 Sink
Source-- "input" -->DecodeJSON
DecodeJSON-- "output" -->Sink
classDef block height:48px,padding:8px;
classDef hidden visibility:none;
class DecodeJSON block
class Source hidden
class Sink hidden
§Sequence Diagram
sequenceDiagram
autonumber
participant BlockA as Another block
participant DecodeJSON.input as DecodeJSON.input port
participant DecodeJSON as DecodeJSON block
participant DecodeJSON.output as DecodeJSON.output port
participant BlockB as Another block
BlockA-->>DecodeJSON: Connect
DecodeJSON-->>BlockB: Connect
loop DecodeJSON process
BlockA->>DecodeJSON: Message (Bytes)
DecodeJSON->>DecodeJSON: Decode from JSON
DecodeJSON->>BlockB: Message
end
BlockA-->>DecodeJSON: Disconnect
DecodeJSON-->>DecodeJSON.input: Close
DecodeJSON-->>DecodeJSON.output: Close
DecodeJSON-->>BlockB: Disconnect
§Examples
§Using the block in a system
System::build(|s| {
// TODO
});§Running the block via the CLI
$ protoflow execute DecodeJSONFields§
§input: InputPort<Bytes>The input message byte stream.
output: OutputPort<Value>The output JSON value.
Implementations§
Source§impl DecodeJson
impl DecodeJson
pub fn new(input: InputPort<Bytes>, output: OutputPort<Value>) -> Self
pub fn with_system(system: &System) -> Self
Trait Implementations§
Source§impl Block for DecodeJson
impl Block for DecodeJson
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 DecodeJson
impl BlockDescriptor for DecodeJson
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 Clone for DecodeJson
impl Clone for DecodeJson
Source§fn clone(&self) -> DecodeJson
fn clone(&self) -> DecodeJson
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl MaybeLabeled for DecodeJson
impl MaybeLabeled for DecodeJson
Source§impl MaybeNamed for DecodeJson
impl MaybeNamed for DecodeJson
Source§impl StdioSystem for DecodeJson
impl StdioSystem for DecodeJson
fn build_system(config: StdioConfig) -> Result<System, StdioError>
Auto Trait Implementations§
impl Freeze for DecodeJson
impl !RefUnwindSafe for DecodeJson
impl Send for DecodeJson
impl Sync for DecodeJson
impl Unpin for DecodeJson
impl !UnwindSafe for DecodeJson
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