Skip to content

Commit 67d83ac

Browse files
committed
Further details on channel idea
1 parent 188167c commit 67d83ac

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

doc/guide-ffi.md

+6
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,12 @@ channel where the writing end (`Chan`) is used exclusively from the C callback
329329
to queue events. The reading end (`Port`) is used in the Rust task which owns
330330
the wrapper object.
331331

332+
Depending on the type of data in the event you might want to convert callback
333+
data from C into a more suitable Rust structure before sending it into the
334+
channel. E.g. it makes sense to convert C strings (`char*`) into Rust strings.
335+
You could also use Rust enumerations to differentiate between multiple types
336+
of events and their data.
337+
332338
Putting this together a wrapper for a library that uses a background thread
333339
that sends events could look like:
334340

0 commit comments

Comments
 (0)