Skip to content

Pinning error using watcher or reflector (cannot be unpinned) #1624

Answered by clux
floric asked this question in Q&A
Discussion options

You must be logged in to vote

Basically, it's because of Unpin requirements on the stream. To simplify it a bit, the futures used by the various stream implementations has a degree of self-referentiality and cannot be moved in async contexts / multi-threaded executors. This blog post is perhaps useful for the understanding.

To satisfy Unpin you can pin it to the stack with the stdlib's std::pin::pin macro, ala node_watcher, or, more safely (because this can consume a lot of stack size), you can put it on the heap via Box::pin, commonly invoked via StreamExt::boxed as seen in the crd_reflector ex.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@floric
Comment options

Answer selected by floric
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants