Closed najamelan closed 5 years ago
Makes sense. Initially I'd planned to keep NngMsg a 1:1 wrapper around nng's C methods and move the ergonomics to MsgBuilder. This is the approach taken in nng.Netcore, but it only makes sense there because managed-to-unmanaged calls have overhead and you'd want to avoid them completely. Since they should be zero-cost in rust, I might as well completely hide the C API. You can always call the original functions through runng-sys anyway. Thanks for pointing this out.
Ok, sorry about this. I completely missed the MsgBuilder. I shall use that for now. That being said, yeah, converting the pointer should be without overhead and it would make the API cleaner.
Got rid of MsgBuilder and added append_slice
to NngMsg
The methods on NngMsg take things like
*const u8
. For creating a msg, I have the impression we have no choice but to build the body withappend
for example.The API would be much more rust idiomatic and convenient if you took
&[u8]
and converted to pointer internally. Also&[u8]
has alen
method, so the user would not have to supply a second parameter forsize
.