Skip to main content

Pid

Struct Pid 

Source
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

Source

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);
Source

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().

Source

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());
Source

pub fn node(&self) -> Atom

Returns the node atom.

Source

pub fn node_name(&self) -> String

Returns the node name as a string.

Source

pub const fn id(&self) -> u64

Returns the process identifier within the node.

Source

pub const fn creation(&self) -> u32

Returns the creation number.

The creation number distinguishes PIDs across node restarts.

Source

pub fn is_local(&self) -> bool

Returns true if this is a local process.

A PID is local if its node matches the current node’s name.

Trait Implementations§

Source§

impl Clone for Pid

Source§

fn clone(&self) -> Pid

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 Pid

Source§

impl Debug for Pid

Source§

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

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

impl Default for Pid

Source§

fn default() -> Pid

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Pid

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Pid, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Pid

Source§

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

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

impl Eq for Pid

Source§

impl Hash for Pid

Source§

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

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 Pid

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Pid

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Pid

Auto Trait Implementations§

§

impl Freeze for Pid

§

impl RefUnwindSafe for Pid

§

impl Send for Pid

§

impl Sync for Pid

§

impl Unpin for Pid

§

impl UnsafeUnpin for Pid

§

impl UnwindSafe for Pid

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> Message for T
where T: Term,

Source§

impl<T> Term for T
where T: Serialize + DeserializeOwned + Send + 'static,

Source§

fn encode(&self) -> Vec<u8>

Encodes this term into bytes. Read more
Source§

fn decode(bytes: &[u8]) -> Result<T, DecodeError>

Decodes a term from bytes. Read more
Source§

fn try_encode(&self) -> Option<Vec<u8>>

Encodes this term, returning None on failure instead of panicking.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.