-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add example flows (top-level) / (metacrate) #24
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM although for some reason I'm unable to run these:
examples/csv_roundtrip.rs
examples/hash_content.rs
examples/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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_size
does not divide the length of the
slice, then the last up tochunk_size-1
elements will be omitted and can be retrieved
from theremainder
function 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]> Signed-off-by: Oleksandr Yakovenko <[email protected]>
Co-authored-by: Samuel Sarle <[email protected]> Signed-off-by: Oleksandr Yakovenko <[email protected]>
No description provided.