Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework Buffer block #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

User344
Copy link
Member

@User344 User344 commented Dec 19, 2024

This PR reworks current Buffer block. It adds another input to act as a trigger to output already stored messages received in main input port.

Here is the simplest example that would buffer a string and then output it each time ReadStdin block outputs anything (on new line).

use protoflow_blocks::*;
fn main() {
	System::run(|s| {
		let stdin = s.read_stdin();
		let hello = s.const_string("Hello, World!");
		let encode = s.encode_lines();
		let buffer = s.buffer();
		let stdout = s.write_stdout();
		s.connect(&hello.output, &encode.input);
		s.connect(&encode.output, &buffer.input);
		s.connect(&stdin.output, &buffer.trigger);
		s.connect(&buffer.output, &stdout.input);
	});
}

I am not sure what to do with StdioSystem implementation so for now I left it as it was before, meaning it just eats input and outputs nothing.

@User344 User344 added the enhancement New feature or request label Dec 19, 2024
@User344 User344 requested a review from artob as a code owner December 19, 2024 11:20
@User344 User344 mentioned this pull request Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant