Struct fp_rust::cor::Cor [−][src]
pub struct Cor<RETURN: 'static, RECEIVE: 'static> { /* fields omitted */ }
Expand description
The Cor
implements a PythonicGenerator-like Coroutine.
Arguments
RETURN
- The generic type of returned dataRECEIVE
- The generic type of received data
Remarks
It could be sync or async up to your usages,
and it could use yield_from
to send a value to another Cor
object and get the response,
and use yield_ref
()/yield_none
() to return my response to the callee of mine.
NOTE: Beware the deadlock if it’s sync(waiting for each other), except the entry point.
Implementations
Generate a new Cor
with the given FnMut
function for the execution of this Cor
.
Arguments
effect
- The givenFnMut
, the execution code ofCor
.
Generate a new Arc<Mutex<Cor<RETURN, RECEIVE>>>
with the given FnMut
function for the execution of this Cor
.
Arguments
effect
- The givenFnMut
, the execution code ofCor
.
Make this
sends a given Option<RECEIVETARGET>
to target
,
and this method returns the Option<RETURNTARGET>
response from target
.
Arguments
this
- The sender when sendingsent_to_inside
totarget
.target
- The receiver of valuesent_to_inside
sent bythis
.sent_to_inside
- The value sent bythis
and received bytarget
.
Remarks
This method is implemented according to some coroutine/generator implementations,
such as Python
, Lua
, ECMASript
…etc.
Make this
returns a given None::<RETURN>
to its callee Cor
,
and this method returns the Option<RECEIVE>
value given from outside.
Arguments
this
- The sender when sendinggiven_to_outside
to calleeCor
.
Remarks
This method is implemented according to some coroutine/generator implementations,
such as Python
, Lua
, ECMASript
…etc.
Make this
returns a given Option<RETURN>
given_to_outside
to its callee Cor
,
and this method returns the Option<RECEIVE>
value given from outside.
Arguments
this
- The sender when sendinggiven_to_outside
to calleeCor
.given_to_outside
- The value sent bythis
and received bytarget
.
Remarks
This method is implemented according to some coroutine/generator implementations,
such as Python
, Lua
, ECMASript
…etc.
Start this
Cor
.
Arguments
this
- The targetCor
to start.
NOTE: Beware the deadlock if it’s sync(waiting for each other), except the entry point.
Setup async or not.
Default async
: true
Arguments
async
- async whentrue
, otherwisesync
.
NOTE: Beware the deadlock if it’s sync(waiting for each other), except the entry point.
Did this Cor
start?
Return true
when it did started (no matter it has stopped or not)
Is this Cor
alive?
Return true
when it has started and not stopped yet.
Trait Implementations
Auto Trait Implementations
impl<RETURN, RECEIVE> RefUnwindSafe for Cor<RETURN, RECEIVE>
impl<RETURN, RECEIVE> UnwindSafe for Cor<RETURN, RECEIVE>
Blanket Implementations
Mutably borrows from an owned value. Read more