C Interface - #28
Conversation
|
I think this could use a bit more commenting, just to understand what each function expects and outputs (does it work on files directly, does it work on text streams?). Also I see a lot of "unsafe" blocks, are those workarounds for the borrow checker or can things be handled safely, from a memory standpoint? |
|
The unsafe blocks are required at some point for interfacing with C. from_ptr always has to be in an unsafe block due to the boundary of what is happening in C or Rust. The rust code has no way to absolutely prove that the pointer points to a valid string in memory. The intent is to keep the unsafe blocks isolated to just the C interface. Happy to explore other options, I just don't think it's entirely possible to remove them. As for documentation, yeah I'll get that done. |
Penaz91
left a comment
There was a problem hiding this comment.
Thanks for the explanation, we can go forward with this and eventually if the need arises we can just make some edits.
Penaz91
left a comment
There was a problem hiding this comment.
Nothing odd stands out to me. I think this can work for now.
Can now be built 2 ways:
wasm-pack build --scope libresplit --target web --release --features wasmThis builds a WASM library, for use on the web.
Output to the pkg folder.
cargo build --releaseThis builds a native library, for use with C.
Output to the target folder.
Example C usage: