pub struct Def<CTX: Context> { /* private fields */ }
Expand description
Process definition.
Implementations§
Source§impl<CTX: Context> Def<CTX>
impl<CTX: Context> Def<CTX>
Sourcepub fn define(
id: CTX::PID,
kind: Kind,
sourcepoints: Vec<CTX::CID>,
endpoints: Vec<CTX::CID>,
) -> Result<Self, Vec<DefineError>>
pub fn define( id: CTX::PID, kind: Kind, sourcepoints: Vec<CTX::CID>, endpoints: Vec<CTX::CID>, ) -> Result<Self, Vec<DefineError>>
The only method to create a valid process def struct. Checks for duplicate sourcepoints or endpoints, self-loops, and restrictions on process kind (asynchronous processes are incompatible with certain combinations of backends).
§Errors
Duplicate sourcepoint:
let result = process::Def::<Mycontext>::define (
ProcessId::A,
process::Kind::isochronous_default(),
vec![ChannelId::X, ChannelId::Z, ChannelId::X],
vec![ChannelId::Y]);
assert_eq!(
result, Err (vec![process::DefineError::DuplicateSourcepoint]));
Duplicate endpoint:
let result = process::Def::<Mycontext>::define (
ProcessId::A,
process::Kind::isochronous_default(),
vec![ChannelId::X, ChannelId::Z],
vec![ChannelId::Y, ChannelId::Y]);
assert_eq!(
result, Err (vec![process::DefineError::DuplicateEndpoint]));
Self-loop:
let result = process::Def::<Mycontext>::define (
ProcessId::A,
process::Kind::isochronous_default(),
vec![ChannelId::X, ChannelId::Z],
vec![ChannelId::Y, ChannelId::Z]);
assert_eq!(
result, Err (vec![process::DefineError::SourcepointEqEndpoint]));
Asynchronous process zero endpoints:
let result = process::Def::<Mycontext>::define (
ProcessId::A,
process::Kind::asynchronous_default(),
vec![ChannelId::Z],
vec![]);
assert_eq!(
result,
Err (vec![process::DefineError::AsynchronousZeroEndpoints]));
Asynchronous process multiple endpoints:
let result = process::Def::<Mycontext>::define (
ProcessId::A,
process::Kind::asynchronous_default(),
vec![ChannelId::Z],
vec![ChannelId::X, ChannelId::Y]);
assert_eq!(
result,
Err (vec![process::DefineError::AsynchronousMultipleEndpoints]));
pub const fn id(&self) -> &CTX::PID
pub const fn kind(&self) -> &Kind
pub const fn sourcepoints(&self) -> &Vec<CTX::CID>
pub const fn endpoints(&self) -> &Vec<CTX::CID>
Trait Implementations§
impl<CTX: Eq + Context> Eq for Def<CTX>
impl<CTX: Context> StructuralPartialEq for Def<CTX>
Auto Trait Implementations§
impl<CTX> Freeze for Def<CTX>
impl<CTX> RefUnwindSafe for Def<CTX>
impl<CTX> Send for Def<CTX>
impl<CTX> Sync for Def<CTX>
impl<CTX> Unpin for Def<CTX>
impl<CTX> UnwindSafe for Def<CTX>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more