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: StringDevice directive: auto (node’s fastest) or a name (cpu, metal, …).
heap_bytes: Option<usize>§role: NodeRoleImplementations§
Source§impl NodeConfig
impl NodeConfig
pub fn new(rank: u32, world: u32) -> Self
Sourcepub fn peers<I, S>(self, addrs: I) -> Result<Self, String>
pub fn peers<I, S>(self, addrs: I) -> Result<Self, String>
Static peer list.
Accepts either form:
worldaddresses, 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.
Sourcepub fn discover(self, disc_port: u16, data_base: u16) -> Self
pub fn discover(self, disc_port: u16, data_base: u16) -> Self
Zero-config UDP peer discovery on a shared LAN.
Sourcepub fn discover_via(self, host: impl Into<String>) -> Self
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.
pub fn topology(self, t: Topology) -> Self
Sourcepub fn star(self) -> Self
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.
pub fn device(self, d: impl Into<String>) -> Self
pub fn heap_bytes(self, n: usize) -> Self
pub fn role(self, r: NodeRole) -> Self
Sourcepub fn fixed_function(self, ff: FixedFunction) -> Self
pub fn fixed_function(self, ff: FixedFunction) -> Self
Declare this node a pre-synthesized fixed-function rank.
Sourcepub fn from_env() -> Result<Self, String>
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.
Sourcepub fn connect(&self) -> Result<Arc<ProcessGroup>>
pub fn connect(&self) -> Result<Arc<ProcessGroup>>
Build the transport and join the mesh.
Trait Implementations§
Source§impl Clone for NodeConfig
impl Clone for NodeConfig
Source§fn clone(&self) -> NodeConfig
fn clone(&self) -> NodeConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for NodeConfig
impl RefUnwindSafe for NodeConfig
impl Send for NodeConfig
impl Sync for NodeConfig
impl Unpin for NodeConfig
impl UnsafeUnpin for NodeConfig
impl UnwindSafe for NodeConfig
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
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> ⓘ
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> ⓘ
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