Module port

Source
Expand description

Port collection macros for AtomVM

Provides safe Rust wrappers around AtomVM’s port driver API

§Design Philosophy

All operations work with any AtomTableOps implementation through dependency injection. No global state, no hardcoded dependencies.

Structs§

AtomVMPortDriver
Port driver registration structure
GenericPortData
Generic port data wrapper with standard functionality

Enums§

PortError
Error handling for port operations
PortResult
Port result enum

Traits§

PortData
Trait for port data types to implement cleanup and message handling

Functions§

create_error_reply
Create a standard error reply using any atom table
create_ok_reply
Create a standard success reply using any atom table
create_port_with_data
Create a port with automatic platform data setup
create_port_with_data_and_term
Create a port with data and user term
handle_standard_message
Generic standard message handler template
parse_gen_message
Helper functions for port message handling Parse a generic port message into its components
parse_port_message
Parse a generic port message into components
port_send_message_from_task
Send an async message to an Erlang process from any context (ISR-safe)
port_send_reply
Send a reply to an Erlang process from port context
send_async_message
Send an async message to an Erlang process (ISR-safe)
send_reply
Send a reply to an Erlang process
term_to_pid
Utility functions for common port operations Extract PID as u32 from Term (for use in async messaging)
with_port_data
Safely execute a function with port data
with_port_data_mut
Safely execute a function with mutable port data

Type Aliases§

ERL_NIF_TERM
ErlNifEnv
Message
Port message type
PortCreateFn
PortDestroyFn
PortHandlerFn
PortInitFn
Port driver function type signatures
PortOpResult
Result type for port operations