-
Notifications
You must be signed in to change notification settings - Fork 0
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
Unify FFI calls with an example on C# #114
base: csharp/integ_yuryf_rust
Are you sure you want to change the base?
Conversation
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
@@ -94,6 +98,16 @@ private void FailureCallback(ulong index) | |||
|
|||
#region FFI function declarations | |||
|
|||
public enum RequestType : uint |
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.
can we remove that and share the RequestType in the header file?
I'm not sure we need to convert from RequestType to RequestType to Cmd when it's 1:1:1.
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.
It is possible. We can define the enum into a C header file and then import it to C# project and to rust (using bindgen).
We can also use protoc to do this for us and suppress a warning about not-FFI-safe enum.
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
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.
I'm not familiar with C# or Rust but don't see any problems with this. Will just have to clean up a bit if this becomes a non-draft (eg removing the commented out prints etc)
) -> Result<Vec<String>, Utf8Error> { | ||
from_raw_parts(data, len) | ||
.iter() | ||
.map(|arg| CStr::from_ptr(*arg).to_str().map(ToString::to_string)) |
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.
use CString
The C signature of new FFI function is