Expand description
§Overview
Motore is a library of the basic abstractions of middlewares for building robust networking clients and servers.
Motore is greatly inspired by the tower crate, and we have used / modified
some of Tower’s code and documentation. We really appreciate the work that
the Tower team have done.
Tower is licensed under the MIT license, and a copy can be found under
the licenses/tower directory.
Motore provides a simple core abstraction, the Service trait, which
represents an asynchronous function taking a request and returning either a
response or an error. This abstraction can be used to model both clients and
servers.
Generic components, like timeouts, rate limiting, and load balancing,
can be modeled as Services that wrap some inner service and apply
additional behavior before or after the inner service is called. This allows
implementing these components in a protocol-agnostic, composable way. Typically,
such services are referred to as middleware.
An additional abstraction, the Layer trait, is used to compose
middleware with Services. If a Service can be thought of as an
asynchronous function from a request type to a response type, a Layer is
a function taking a Service of one type and returning a Service of a
different type. The ServiceBuilder type is used to add middleware to a
service by composing it with multiple Layers.
Re-exports§
pub use service::BoxCloneService;pub use service::Service;pub use service::ServiceExt;pub use service::UnaryService;
Modules§
- builder
- Builder types to compose layers and services
- layer
- Layer traits and extensions.
- make
- Pre-defined Service traits that may be useful for specified use cases.
- service
- Definition of the core
Servicetrait to Motore. - timeout
- Applies a timeout to request if the inner service’s call does not complete within specified timeout, the response will be aborted.
- utils
Type Aliases§
- BoxError
- Alias for a type-erased error type.
Attribute Macros§
- service
- This macro can help you to write a
Servicein a more efficient way.