Module tide_disco::method

source ·
Expand description

Interfaces for methods of accessing to state.

A common pattern is for the State type of an App to enable some form of interior mutability, with the option of read-only access, such as [RwLock]. Route handlers will then acquire either shared immutable access or exclusive mutable access, where the access mutability is linked to the HTTP method of the route – a GET method implies immutable access, for example, while a POST method implies mutable access.

tide-disco supports this pattern ergonomically for any state type which has a notion of reading and writing. This module defines the traits ReadState and WriteState for states which support immutable and mutable access, respectively, and implements the traits for commonly used types such as [RwLock], [Mutex], and Arc. Of course, you are free to implement these traits yourself if your state type has some other notion of shared access or interior mutability.




  • A state which allows read access.
  • A state which allows exclusive, write access.