Skip to main content

RoleId

Struct RoleId 

Source
pub struct RoleId(/* private fields */);
Expand description

A validated, nonzero numeric region role.

Implementations§

Source§

impl RoleId

Source

pub const fn new(value: u32) -> Option<Self>

Creates a role, rejecting the reserved zero value.

Examples found in repository?
examples/checked_layout.rs (line 8)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let requests = RoleId::new(1).expect("nonzero role");
9    let responses = RoleId::new(2).expect("nonzero role");
10    let regions = [
11        RegionSpec {
12            role: requests,
13            writer: Endpoint::Initiator,
14            slot_count: 1,
15            payload_bytes: 256,
16            acknowledgement_count: 1,
17        },
18        RegionSpec {
19            role: responses,
20            writer: Endpoint::Responder,
21            slot_count: 1,
22            payload_bytes: 256,
23            acknowledgement_count: 1,
24        },
25    ];
26    let routes = [
27        AcknowledgementRouteSpec {
28            owner: responses,
29            target: requests,
30            slot_index: 0,
31            cell_index: 0,
32        },
33        AcknowledgementRouteSpec {
34            owner: requests,
35            target: responses,
36            slot_index: 0,
37            cell_index: 0,
38        },
39    ];
40    let limits = LayoutLimits {
41        maximum_mapping_size: 64 * 1024,
42        maximum_slot_count: 8,
43        maximum_acknowledgement_count: 8,
44        maximum_payload_bytes: 4096,
45    };
46
47    let topology = RegionSetLayout::calculate([0x52; 32], 1, &regions, &routes, limits)?;
48    for region in topology.regions() {
49        println!(
50            "role={} writer={:?} mapping={} bytes",
51            region.role().get(),
52            region.writer(),
53            region.total_size()
54        );
55    }
56    Ok(())
57}
Source

pub const fn get(self) -> u32

Returns the fixed-width wire value.

Examples found in repository?
examples/checked_layout.rs (line 51)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let requests = RoleId::new(1).expect("nonzero role");
9    let responses = RoleId::new(2).expect("nonzero role");
10    let regions = [
11        RegionSpec {
12            role: requests,
13            writer: Endpoint::Initiator,
14            slot_count: 1,
15            payload_bytes: 256,
16            acknowledgement_count: 1,
17        },
18        RegionSpec {
19            role: responses,
20            writer: Endpoint::Responder,
21            slot_count: 1,
22            payload_bytes: 256,
23            acknowledgement_count: 1,
24        },
25    ];
26    let routes = [
27        AcknowledgementRouteSpec {
28            owner: responses,
29            target: requests,
30            slot_index: 0,
31            cell_index: 0,
32        },
33        AcknowledgementRouteSpec {
34            owner: requests,
35            target: responses,
36            slot_index: 0,
37            cell_index: 0,
38        },
39    ];
40    let limits = LayoutLimits {
41        maximum_mapping_size: 64 * 1024,
42        maximum_slot_count: 8,
43        maximum_acknowledgement_count: 8,
44        maximum_payload_bytes: 4096,
45    };
46
47    let topology = RegionSetLayout::calculate([0x52; 32], 1, &regions, &routes, limits)?;
48    for region in topology.regions() {
49        println!(
50            "role={} writer={:?} mapping={} bytes",
51            region.role().get(),
52            region.writer(),
53            region.total_size()
54        );
55    }
56    Ok(())
57}

Trait Implementations§

Source§

impl Clone for RoleId

Source§

fn clone(&self) -> RoleId

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RoleId

Source§

impl Debug for RoleId

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for RoleId

Source§

impl Hash for RoleId

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for RoleId

Source§

fn eq(&self, other: &RoleId) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RoleId

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.