Skip to main content

EdgeMesh API reference

EdgeMesh provides local-network device discovery, topology, trust state, and routing helpers.

MeshEngine

@MainActor
public final class MeshEngine: ObservableObject

Central mesh coordinator.

Property or methodDescription
peersDiscovered peers.
topologyCurrent mesh topology.
isDiscoveringDiscovery state.
startDiscovery(as:)Starts local discovery.
stopDiscovery()Stops discovery.
connect(to:)Connects to a trusted peer.
setupSecurity(peerId:displayName:trustStoreURL:)Initializes local identity and trust storage.
installSecurity(identity:trustStore:)Injects prebuilt security state.
completePairing(with:localPeerId:localDisplayName:)Completes pairing from a pairing payload.
listTrustedPeers()Returns trusted peers.
revoke(peerId:)Revokes trust for a peer.
deletePeer(peerId:)Deletes a peer from trust storage and memory.
bestNode(for:strategy:)Selects a node from the current topology.
routingPlan(for:)Builds a routing plan.

MeshNode

public struct MeshNode: Identifiable, Sendable, Hashable

Represents a device in the mesh.

PropertyType
idString
displayNameString
capabilityMeshNode.Capability
deviceProfileMeshNode.MeshDeviceSnapshot
endpointMeshNode.Endpoint
trustStatusMeshNode.TrustStatus

Capability

CaseDescription
.inferenceCan run inference.
.dataData collection node.
.bothBoth inference and data roles.

MeshTopology

public struct MeshTopology: Sendable
APIDescription
tier0, tier1, tier2Nodes grouped by role.
allNodesAll known nodes.
countTotal node count.
addNode(_:)Adds or updates a node.
removeNode(id:)Removes a node.
findNode(id:)Finds a node by ID.

MeshRouter

public struct MeshRouter: Sendable
APIDescription
bestNode(for:in:strategy:)Selects a node for a model size.
routingPlan(for:in:)Returns a RoutingPlan.

Strategy

CaseDescription
.bestFitBalanced default.
.leastLoadedPrefer available memory.
.fastestPrefer bandwidth.

RoutingPlan

public struct RoutingPlan: Sendable
PropertyType
modeRoutingPlan.Mode
primaryNodeMeshNode?
auxiliaryNodes[MeshNode]
estimatedLatencyMsDouble