Skip to main content

GalacticAddress

Struct GalacticAddress 

Source
pub struct GalacticAddress {
    pub reality_index: u8,
    /* private fields */
}
Expand description

A packed 48-bit galactic coordinate plus a galaxy (reality) index.

The 48-bit value encodes fields in portal glyph order: P-SSS-YY-ZZZ-XXX where P=PlanetIndex, SSS=SolarSystemIndex, YY=VoxelY, ZZZ=VoxelZ, XXX=VoxelX.

The reality_index identifies the galaxy (0=Euclid, 1=Hilbert, etc.) and is stored separately from the packed value.

Fields§

§reality_index: u8

Implementations§

Source§

impl GalacticAddress

Source

pub fn new( voxel_x: i16, voxel_y: i8, voxel_z: i16, solar_system_index: u16, planet_index: u8, reality_index: u8, ) -> Self

Create from individual field values (portal coordinate frame).

Source

pub fn from_packed(packed: u64, reality_index: u8) -> Self

Create from raw packed 48-bit value and reality index.

Source

pub fn packed(&self) -> u64

Return the raw 48-bit packed value.

Source

pub fn planet_index(&self) -> u8

Planet index (4-bit unsigned, 0-15). Bits 47-44.

Source

pub fn solar_system_index(&self) -> u16

Solar system index (12-bit unsigned, 0x000-0xFFE). Bits 43-32.

Source

pub fn voxel_y(&self) -> i8

VoxelY (8-bit signed, -128..127). Bits 31-24.

Source

pub fn voxel_z(&self) -> i16

VoxelZ (12-bit signed, -2048..2047). Bits 23-12.

Source

pub fn voxel_x(&self) -> i16

VoxelX (12-bit signed, -2048..2047). Bits 11-0.

Source

pub fn voxel_position(&self) -> (i16, i8, i16)

Voxel coordinates as (x, y, z) signed integers (center-origin).

Source

pub fn from_signal_booster( s: &str, planet_index: u8, reality_index: u8, ) -> Result<Self, AddressParseError>

Parse signal booster format XXXX:YYYY:ZZZZ:SSSS.

Signal booster uses corner-origin unsigned coordinates. The conversion adds fixed offsets to translate into portal-frame (center-origin) values. Does NOT include planet index or reality index; caller must supply those.

Source

pub fn to_signal_booster(&self) -> String

Format as signal booster string XXXX:YYYY:ZZZZ:SSSS.

Converts portal-frame (center-origin) coordinates back to the corner-origin unsigned format used by the in-game signal booster.

Source

pub fn distance_ly(&self, other: &GalacticAddress) -> f64

Distance in light-years to another address.

SSI-aware: returns 0 for same system, VOXEL_UNCERTAINTY for same voxel but different SSI, and Euclidean voxel distance * LY_PER_VOXEL otherwise. Only meaningful for addresses in the same galaxy.

Source

pub fn same_region(&self, other: &GalacticAddress) -> bool

Whether two addresses are in the same region (same VoxelX/Y/Z).

Source

pub fn same_system(&self, other: &GalacticAddress) -> bool

Whether two addresses are in the same system (same region + same SSI).

Source

pub fn within(&self, other: &GalacticAddress, ly: f64) -> bool

Whether another address is within N light-years.

Source

pub fn distance_to_core_ly(&self) -> f64

Distance in light-years from this address to the galactic core (0, 0, 0).

Note: comparing addresses across different galaxies (reality_index) is not physically meaningful.

Source

pub fn is_black_hole(&self) -> bool

Whether this address points to a black hole system (SSI 0x079).

Source

pub fn is_atlas_interface(&self) -> bool

Whether this address points to an Atlas Interface system (SSI 0x07A).

Source

pub fn is_purple_system(&self) -> bool

Whether this address is in the purple system SSI range (0x3E8-0x429).

Source§

impl GalacticAddress

Source

pub fn to_portal_address(&self) -> PortalAddress

Convert to PortalAddress.

Source

pub fn from_portal_string(s: &str) -> Result<Self, PortalParseError>

Create from a portal address string (hex, emoji, or mixed). Reality index defaults to 0.

Trait Implementations§

Source§

impl Clone for GalacticAddress

Source§

fn clone(&self) -> GalacticAddress

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 GalacticAddress

Source§

impl Debug for GalacticAddress

Source§

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

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

impl<'de> Deserialize<'de> for GalacticAddress

Source§

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

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

impl Display for GalacticAddress

Display as 0x followed by 12 uppercase hex digits.

Source§

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

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

impl Eq for GalacticAddress

Source§

impl From<GalacticAddress> for u64

Into raw packed u64 (drops reality_index).

Source§

fn from(addr: GalacticAddress) -> u64

Converts to this type from the input type.
Source§

impl From<GalacticAddress> for PortalAddress

Source§

fn from(addr: GalacticAddress) -> Self

Convert galactic address to portal address.

Extracts each nibble from the packed 48-bit value.

Source§

impl From<PortalAddress> for GalacticAddress

Source§

fn from(pa: PortalAddress) -> Self

Convert portal address to galactic address.

Portal glyph layout: P-SSS-YY-ZZZ-XXX (glyph positions 0-indexed: [0]=P, [1-3]=SSS, [4-5]=YY, [6-8]=ZZZ, [9-11]=XXX). Reality index defaults to 0.

Source§

impl From<u64> for GalacticAddress

From raw packed u64 (reality_index defaults to 0).

Source§

fn from(packed: u64) -> Self

Converts to this type from the input type.
Source§

impl FromStr for GalacticAddress

Parse from 0x/0X prefix + 12 hex digits, or bare 12 hex digits. Reality index defaults to 0.

Source§

type Err = AddressParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for GalacticAddress

Source§

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

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 GalacticAddress

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for GalacticAddress

Source§

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

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

impl StructuralPartialEq for GalacticAddress

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

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> 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 = !

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.