[−][src]Crate cb_fut
Make a call to callback function without callback function.
This crate provide 2 macros to turn a call to function that require a callback parameter
for return values into a function call that return a Future
of that values.
These macro introduce an indirection layer to glue callback to Future
thus
it has some additional overhead.
Limitation
- If the callback is not intended to return a value, don't use these two macros.
- If the function also return value, the returned value will be silently dropped.
- If the function take multiple callbacks to return value on different circumstance, don't use these two macros.
What's new in version 0.2.0
- once_blocked - which let user return value to function.
- stream_blocked - which let user return value to Stream.
- By default, it will use Rust standard channel. Now it also support
Crossbeam-channel
. To use this feature, add features=["crossbeam"] to yourcargo.toml
. For example:
[dependencies]
cb_fut = {version = "^0.2", features = ["crossbeam"]}
Macros
once | Turn a function call that take a single callback function and return nothing into a function call without callback that return a future value. |
once_blocked | Turn a function call that take a single callback function to return a value
then wait for callback to return another value to continue it execution into a function
that return a |
stream | Turn a function call that take a single callback and return nothing into a function call
without callback but return an implementation of |
stream_blocked | Turn a function call that take a single callback and return nothing into a function call
without callback but return an implementation of |
Structs
AlreadyReturnError | It mean that the value already return once and caller attempt to return something again. |
CBBlockResult | A structure that act as handle to retrieve result as well as return a value to function. |
CBStream | A represent of callback function arguments which implement |
CBStreamBlocked | An object that represent callback function arguments. It implement |
Functions
channel | Utility function intended to be used internally. It will return a channel regarding to feature gate. The default is to use standard channel. |