pub struct Pid { /* private fields */ }Expand description
A process identifier.
Every process in Starlang has a unique Pid that can be used to send messages,
establish links, create monitors, and query process status.
The node is stored as an Atom (interned string) for global uniqueness.
Display format matches Erlang’s <node.id.creation> convention, showing
<0.id.creation> for local PIDs and <N.id.creation> for remote ones.
§Examples
use starlang_core::Pid;
let pid = Pid::new();
println!("Process: {}", pid); // e.g., "<0.42.0>"
// Pids can be compared
let pid2 = Pid::new();
assert_ne!(pid, pid2);Implementations§
Source§impl Pid
impl Pid
Sourcepub fn new() -> Pid
pub fn new() -> Pid
Creates a new unique process identifier on the local node.
Each call to new() returns a globally unique Pid.
The node is set to the current node’s name atom.
§Examples
use starlang_core::Pid;
let pid1 = Pid::new();
let pid2 = Pid::new();
assert_ne!(pid1, pid2);Sourcepub fn from_parts_atom(node: Atom, id: u64, creation: u32) -> Pid
pub fn from_parts_atom(node: Atom, id: u64, creation: u32) -> Pid
Creates a Pid with a specific node atom, id, and creation values.
This is primarily used for deserialization and testing. In normal usage,
prefer Pid::new().
Sourcepub fn remote(node_name: &str, id: u64, creation: u32) -> Pid
pub fn remote(node_name: &str, id: u64, creation: u32) -> Pid
Creates a remote Pid for a process on another node.
This is used when receiving PIDs from remote nodes during distribution.
§Examples
use starlang_core::Pid;
use starlang_atom::atom;
let remote_pid = Pid::remote("node2@localhost", 100, 5);
assert!(!remote_pid.is_local());