pontil/platform
Cross-runtime platform detection.
Provides typed detection of runtime environment, operating system, and CPU architecture across both Erlang and JavaScript targets.
Types
The CPU architecture.
pub type Arch {
Arm
Arm64
X86
X64
Loong64
Mips
MipsLittleEndian
PPC
PPC64
RiscV64
S390
S390X
OtherArch(String)
}
Constructors
-
Arm -
Arm64 -
X86 -
X64 -
Loong64 -
Mips -
MipsLittleEndian -
PPC -
PPC64 -
RiscV64 -
S390 -
S390X -
OtherArch(String)
The operating system.
pub type Os {
Aix
Darwin
FreeBsd
Linux
OpenBsd
SunOs
Win32
OtherOs(String)
}
Constructors
-
Aix -
Darwin -
FreeBsd -
Linux -
OpenBsd -
SunOs -
Win32 -
OtherOs(String)
Platform details.
pub type PlatformInfo {
PlatformInfo(
name: String,
version: String,
runtime: Runtime,
runtime_version: String,
os: Os,
arch: Arch,
)
}
Constructors
-
PlatformInfo( name: String, version: String, runtime: Runtime, runtime_version: String, os: Os, arch: Arch, )Arguments
- name
-
The name of the Operating System release. This will be
""if the value cannot be determined. - version
-
The version of the Operating System release. This will be
""if the value cannot be determined. - runtime
-
The runtime environment.
- runtime_version
-
The runtime version string.
- os
-
The operating system.
Values
pub fn arch_to_string(arch: Arch) -> String
Returns a string representation of an Arch value.
pub fn details() -> PlatformInfo
Returns full platform details including OS release name and version.
pub fn os_to_string(os: Os) -> String
Returns a string representation of an Os value.
pub fn runtime_to_string(runtime: Runtime) -> String
Returns a string representation of a Runtime value.
pub fn runtime_version() -> String
Returns the version string of the current runtime.
- Erlang: OTP release (e.g.
"27") - Node: version without
vprefix (e.g."24.0.0") - Bun: version (e.g.
"1.1.0") - Deno: version (e.g.
"2.0.0") - Browser:
"browser"
In the browser, the value browser is returned because the only useful
value, navigator.appVersion or navigator.userAgent, is completely
useless as a simple version. If you are using pontil/platform in
a browser, you will need to parse navigator.userAgent directly.