Monitoring an external process within an FFI

During your time using a computer, you will have no doubt seen an image like the following:

These progress bars work in a similar way to each other. Say you have a process that has five equal sized portions or you're downloading a file from the internet. As the portion completes or an amount of code is downloaded, the bar and percentage are updated using a programming technique known as a callback.

How a callback is implemented depends on the language being used. For example, in an event-driven language, the process will either emit a signal or generate an event that the receiver listens for. When the signal/event is received, the user interface is updated.

Rust is no different; it is able to use a callback when using an FFI. Rust is capable of working with both synchronous and asynchronous callbacks. It is also possible to target a callback to a Rust object.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset