diff --git a/doc/guide-ffi.md b/doc/guide-ffi.md index 4387d5d764e..a33593007dc 100644 --- a/doc/guide-ffi.md +++ b/doc/guide-ffi.md @@ -329,6 +329,12 @@ channel where the writing end (`Chan`) is used exclusively from the C callback to queue events. The reading end (`Port`) is used in the Rust task which owns the wrapper object. +Depending on the type of data in the event you might want to convert callback +data from C into a more suitable Rust structure before sending it into the +channel. E.g. it makes sense to convert C strings (`char*`) into Rust strings. +You could also use Rust enumerations to differentiate between multiple types +of events and their data. + Putting this together a wrapper for a library that uses a background thread that sends events could look like: