Add example flows (top-level) / (metacrate)#24
Add example flows (top-level) / (metacrate)#24oleksandrvoyager wants to merge 9 commits intomasterfrom
Conversation
SamuelSarle
left a comment
There was a problem hiding this comment.
LGTM although for some reason I'm unable to run these:
examples/csv_roundtrip.rsexamples/hash_content.rsexamples/log_directories.rs
Were you able to run those? They give import errors that I haven't been able to solve for TextBlocks::concat_strings_by, TextBlocks::decode_csv, TextBlocks::encode_csv, and HashBlocks::hash_sha2.
Specifically that would be the implementations missing for protoflow_blocks::System but of course all of those are present in the repo (lib/protoflow-blocks/src/system.rs)
Examples:
error[E0599]: no method named `encode_csv` found for mutable reference `&mut protoflow::protoflow_blocks::System` in the current scope
error[E0599]: no method named `decode_csv` found for mutable reference `&mut protoflow::protoflow_blocks::System` in the current scope
error[E0599]: no method named `hash_sha2` found for mutable reference `&mut protoflow::protoflow_blocks::System` in the current scope
error[E0599]: no method named `concat_strings_by` found for mutable reference `&mut protoflow::protoflow_blocks::System` in the current scope
| let json = s.const_string(r#"{"Name": "Alice","Age": 25,"Score": 90}"#); | ||
|
|
||
| let line_encoder = s.encode_lines(); | ||
| s.connect(&json.output, &line_encoder.input); |
There was a problem hiding this comment.
In the future we should probably implement a Const helper which can output Bytes from a string. This behaves correctly but the line_encoder looks a bit funny here :)
| let input_string = s.const_string("The quick brown fox jumps over the lazy dog"); | ||
|
|
||
| let encoder = s.encode_lines(); | ||
| s.connect(&input_string.output, &encoder.input); |
There was a problem hiding this comment.
Likewise for here as hex("$string\n") != hex("$string")
| let input_string = s.const_string("54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f670a"); | ||
|
|
||
| let encoder = s.encode_lines(); | ||
| s.connect(&input_string.output, &encoder.input); | ||
|
|
||
| let hex_decoder = s.decode_hex(); | ||
| s.connect(&encoder.output, &hex_decoder.input); |
There was a problem hiding this comment.
Same problem, with interesting behaviour with DecodeHex! This appends a newline at the end before sending it to DecodeHex which should result in an error. But DecodeHex uses Bytes::chunks_exact(2) which leaves the newline character alone as it's one byte:
The chunks are slices and do not overlap. If
chunk_sizedoes not divide the length of the
slice, then the last up tochunk_size-1elements will be omitted and can be retrieved
from theremainderfunction of the iterator.
I think that DecodeHex shouldn't accept and ignore the last byte silently so we should make a PR so that it checks the content length is divisible by two.
| let content = s.const_string("Hello, World!"); | ||
| let line_encoder = s.encode_lines(); | ||
| let hash_content = s.hash_sha2(); |
There was a problem hiding this comment.
Not able to run this file directly but copying the code to somewhere else you get
$ echo "Hello, World!" | sha256sum
c98c24b677eff44860afea6f493bbaec5bb1c4cbb209c6fc2bbb47f66ff2ad31
instead of the correct
$ echo -n "Hello, World!" | sha256sum
dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f
due to the s.encode_lines() adding a newline that also gets hashed.
Co-authored-by: Samuel Sarle <samuel@sarle.com> Signed-off-by: Oleksandr Yakovenko <35838571+AlexSanches1@users.noreply.github.com>
Co-authored-by: Samuel Sarle <samuel@sarle.com> Signed-off-by: Oleksandr Yakovenko <35838571+AlexSanches1@users.noreply.github.com>
|
@race-of-sloths invite |
|
@oleksandrvoyager Thank you for your contribution! Your pull request is now a part of the Race of Sloths! Current status: staleThis pull request was removed from the race, but you can include it again with What is the Race of SlothsRace of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow For contributors:
For maintainers:
Feel free to check our website for additional details! Bot commands
|
|
@race-of-sloths score 13 |
|
Important Protoflow has been discontinued and archived in favor of its successors Async-Flow and Flows.rs, which represent the future of flow-based programming in Rust and offer a substantially better developer experience as well as simply higher development velocity. We aim to eventually port the functionality in this pull request over to Flows.rs; if you'd like to contribute to make that happen sooner, please raise an issue and/or pull request against that repository. |
No description provided.