#android #looper #wrapper #thin #docs #reference #object

android_looper

Thin wrapper for Android Looper

2 unstable releases

Uses old Rust 2015

0.3.0 Feb 8, 2019
0.1.0 Apr 30, 2016

#6 in #looper

MIT/Apache

9KB
68 lines

Thin wrapper for Android Looper

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Fork me on GitHub <style>.sidebar { margin-top: 53px }</style>

From android docs:

Class used to run a message loop for a thread. Threads by default do not have a message loop associated with them; to create one, call prepare() in the thread that is to run the loop, and then loop() to have it process messages until the loop is stopped.

Library design conventions

This library is a minimal safe wrapper for what otherwise be unsafe ffi bindings. There are few conventions used here that are good to know to make the best use of it.

Safety does not include the correct destruction order

While this library may provide the RAII wrappers (see bellow), it will not keep track of wrapper dependencies. Doing it at this level would require Rc machinery that may cause several problems: force users to use Rc or Arc, complicate implementation, no longer be zero-cost.

Instead, the users are encouraged to build wrappers around these different type kinds (listed bellow) that manage resources as needed for each use case.

Not-copyable struct Object kind

This is RAII type that wraps a low-level resource, provides methods to manipulate it and also destroys it when it goes out of scope. It may also have convenience methods from_handle as constructor and method forget to get back the handle and disable the RAII.

Copyable struct/enum Object kind

Used for tracking intermediate glue information, usually replaces or wraps cumbersome C unions, types or enums.

Copyable struct ObjectRef kind

Wraps a low level handle(s) and provides methods to manipulate it/them. Used in situations where the handle lifetime is controlled by another object or it is some kind of global singleton. In such cases the method calls themselves may return errors when called on expired or invalid handle.

Dependencies

~165KB