Crate smelling_salts
source ·Expand description
Abstraction over OS APIs to handle asynchronous device waking.
Getting Started
Most devices are represented as file descriptors on unix-like operating
systems (MacOS also has run loops). On Windows, devices are usually sockets
or handles. WebAssembly running in the browser doesn’t have a equivalent.
To get around these device backend differences, Smelling Salts exposed an
OsDevice
type which has From
conversions implemented for the
platform types.
An OsDevice
by itself isn’t that useful, though. When you have a handle
to a device, you want to asynchronously watch it for events. For this, you
construct a Device
, which implements Notify
.
But, general devices aren’t that useful either, so you’ll need to wrap it in
your own custom type. Usually, you will filter out some of the events, so
you’ll need to implement Notify
.
Here’s a simple example implementing a Notify
for
stdin line reading:
Structs
- An owned device handle that’s being watched for wake events
- An owned handle to an unwatched OS device
- A bitfield specifying which events to watch for