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 data
  • RECEIVE - 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 given FnMut, the execution code of Cor.

Generate a new Arc<Mutex<Cor<RETURN, RECEIVE>>> with the given FnMut function for the execution of this Cor.

Arguments

  • effect - The given FnMut, the execution code of Cor.

Make this sends a given Option<RECEIVETARGET> to target, and this method returns the Option<RETURNTARGET> response from target.

Arguments

  • this - The sender when sending sent_to_inside to target.
  • target - The receiver of value sent_to_inside sent by this.
  • sent_to_inside - The value sent by this and received by target.

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 sending given_to_outside to callee Cor.

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 sending given_to_outside to callee Cor.
  • given_to_outside - The value sent by this and received by target.

Remarks

This method is implemented according to some coroutine/generator implementations, such as Python, Lua, ECMASript…etc.

Start this Cor.

Arguments

  • this - The target Cor 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 when true, otherwise sync.

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.

Stop Cor. This will make self.is_alive() returns false, and all yield_from() from this Cor as target will return None::<RETURN>. (Because it has stopped :P, that’s reasonable)

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.