Skip to main content

NodeConfig

Struct NodeConfig 

Source
pub struct NodeConfig {
    pub rank: u32,
    pub world: u32,
    pub peers: PeerSource,
    pub topology: Topology,
    pub device: String,
    pub heap_bytes: Option<usize>,
    pub role: NodeRole,
}
Expand description

Programmatic node configuration.

Every field is settable in code. NodeConfig::from_env exists for parity with the CLI workflow, but nothing here requires an environment — an iOS app or an Android service has no meaningful RANK/PEERS to read.

Fields§

§rank: u32§world: u32§peers: PeerSource§topology: Topology§device: String

Device directive: auto (node’s fastest) or a name (cpu, metal, …).

§heap_bytes: Option<usize>§role: NodeRole

Implementations§

Source§

impl NodeConfig

Source

pub fn new(rank: u32, world: u32) -> Self

Source

pub fn peers<I, S>(self, addrs: I) -> Result<Self, String>
where I: IntoIterator<Item = S>, S: Into<String>,

Static peer list.

Accepts either form:

  • world addresses, indexed by rank — a full mesh, where every rank must be able to reach every other.
  • exactly one address — the coordinator, for a star. This is what a phone can actually supply: a handset does not know its own reachable address, and on most Wi-Fi it cannot accept inbound connections at all, so it dials out and nothing dials it.
Source

pub fn discover(self, disc_port: u16, data_base: u16) -> Self

Zero-config UDP peer discovery on a shared LAN.

Source

pub fn discover_via(self, host: impl Into<String>) -> Self

Unicast the discovery query to a known rendezvous host. Use this on networks where UDP broadcast does not reach every peer — which includes most carrier and guest Wi-Fi, and iOS without the multicast entitlement.

Source

pub fn topology(self, t: Topology) -> Self

Source

pub fn star(self) -> Self

Star topology: workers dial the coordinator, which never waits to hear them. This is the shape a phone needs — a handset on Wi-Fi often cannot accept inbound connections, and in a mesh every rank must reach every other.

Source

pub fn mesh(self) -> Self

Full mesh: every rank connects to every other. The default.

Source

pub fn device(self, d: impl Into<String>) -> Self

Source

pub fn heap_bytes(self, n: usize) -> Self

Source

pub fn role(self, r: NodeRole) -> Self

Source

pub fn fixed_function(self, ff: FixedFunction) -> Self

Declare this node a pre-synthesized fixed-function rank.

Source

pub fn from_env() -> Result<Self, String>

Read the same variables the CLI node driver uses (RANK, WORLD, PEERS / DISCOVER, TOPOLOGY, HEAP_MB, DEVICE). Provided for parity; prefer the builder on platforms without a shell environment.

Source

pub fn connect(&self) -> Result<Arc<ProcessGroup>>

Build the transport and join the mesh.

Source

pub fn caps(&self) -> NodeCaps

This node’s advertised capabilities.

Trait Implementations§

Source§

impl Clone for NodeConfig

Source§

fn clone(&self) -> NodeConfig

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 Debug for NodeConfig

Source§

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

Formats the value using the given formatter. Read more

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,