-
Notifications
You must be signed in to change notification settings - Fork 42
C/C++: add server callbacks for on_un/subscribe #274
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
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.
Some minor comments, otherwise looking great
}; | ||
|
||
class Channel final { | ||
public: | ||
Channel(std::string_view topic, std::string_view messageEncoding, std::optional<Schema> schema); | ||
Channel( | ||
const std::string& topic, const std::string& messageEncoding, std::optional<Schema> schema |
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.
The other option is change the C api to take string pointer and length for each argument, but all our strings are pretty short here, null-terminated strings are fine.
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.
yeah - I guess I had two thoughts on that:
const char*
(null terminated) seems pretty normal/expected for a C API- if we passed pointer+length, on the Rust side then we wouldn't be able to use
CStr::from_ptr
, which is not the end of the world, but on the other hand this is exactly what it's designed for.
And another one: because C++ is stupid, technically you can also have a std::string that contains null bytes, so I think I'm viewing this API more as "advice" that the strings you pass in should be null-terminated.
Changelog
Docs
N/A
Description
In addition to the features mentioned above:
string_view
tostring
because I learned thatstring_view
is not necessarily null-terminated, but on the Rust side we assume it is