one_user

Crates.ioone_user
lib.rsone_user
version0.3.2
sourcesrc
created_at2021-04-15 21:10:12.963628
updated_at2022-02-02 11:12:24.285653
descriptionConstrain the number of instances that can possibly be used at a time. By default it constrains it to one instance at a time, hence one_user.
homepage
repositoryhttps://github.com/Error1000/one_user
max_upload_size
id385070
size15,263
(Error1000)

documentation

README

One User

This crate provides a way to make sure a struct is only used by "N users" at a time. It achives this by providing a procedural macro which generates code for forcing only N active "views" (a.k.a mut references to some instances of the struct) at a time. Under the hood this is done by having a bound and unbound version of your struct and then requiring a &mut to a bouncer to give you a bound to a slot, and since bouncers are unique per slot there can only ever be N bounds whre N is the numbers of slots. It also provides a hook for reacting to an instance of your struct being bound to a slot.

Commit count: 19

cargo fmt