Crate tokio_agent

Source
Expand description

“Agents are a simple abstraction around state.”

This crate is inspired by Elixir’s Agent.

In Rust however, an Agent holds your State in either a tokio task, or a thread, and allows you to interact with that state, while having the state remain within the task or thread.

An agent managing state in a thread for examplue could be used to manage and interact with a resource which would cause blocking on the tokio runtime (for example, sqlite database).

An agent managing state in a task could be used to manage and interact with a resource in a lock-free way.

Structs§

BlockingHandle
The “Blocking” variant of Handle which can be used to interact with an Agent outside of a tokio runtime context.
Handle
A Handle allows for interaction with a previously spawned Agent inside of a tokio runtime context.
HandleCommon
Contains common functionality that is shared between Handle and BlockingHandle.
Stopped
The agent that this handle refers to has already been stopped.

Enums§

Agent
See the crate’s main documentation for a description of what an Agent is.

Type Aliases§

Result
A convenience wrapper result type, for use when dealing with the Handle and BlockingHandle API.