Skip to content

API Reference

b23r0 edited this page Oct 12, 2026 · 1 revision

English · 简体中文

公开 API 索引

索引按 1.4.0 源码核对,具体签名、参数及返回类型见链接。&self 不代表 send 已获业务确认,也不代表并发 recv 是广播。

RaknetSocket

方法 API 文档
set_idle_maintenance set_idle_maintenance
mtu mtu
from (async) from
connect (async) connect
connect_with_version (async) connect_with_version
connect_with_version_and_mtu (async) connect_with_version_and_mtu
close (async) close
ping (async) ping
send (async) send
send_with_order_channel (async) send_with_order_channel
send_bytes (async) send_bytes
send_bytes_with_order_channel (async) send_bytes_with_order_channel
send_batch (async) send_batch
send_batch_with_order_channel (async) send_batch_with_order_channel
send_bytes_batch (async) send_bytes_batch
send_bytes_batch_with_order_channel (async) send_bytes_batch_with_order_channel
flush (async) flush
recv (async) recv
recv_bytes (async) recv_bytes
recv_batch (async) recv_batch
recv_bytes_batch (async) recv_bytes_batch
peer_addr peer_addr
local_addr local_addr
raknet_version raknet_version
set_loss_rate set_loss_rate
set_send_options (async) set_send_options
send_options (async) send_options
set_recovery_options (async) set_recovery_options
recovery_options (async) recovery_options

RaknetListener

方法 API 文档
bind (async) bind
bind_with_maximum_mtu (async) bind_with_maximum_mtu
bind_with_socket_shards (async) bind_with_socket_shards
bind_with_receive_buffer_size (async) bind_with_receive_buffer_size
with_accept_backlog with_accept_backlog
with_idle_maintenance with_idle_maintenance
with_receive_batching with_receive_batching
from_std (async) from_std
listen (async) listen
accept (async) accept
get_guid get_guid
set_motd (async) set_motd
get_motd (async) get_motd
local_addr local_addr
close (async) close
set_full_motd (async) set_full_motd
get_peer_raknet_version (async) get_peer_raknet_version

blocking::RaknetRuntime

需要 blocking。

方法 API 文档
new new
with_worker_threads with_worker_threads
connect connect
connect_timeout connect_timeout
connect_with_version connect_with_version
connect_with_version_and_mtu connect_with_version_and_mtu
bind bind
bind_with_maximum_mtu bind_with_maximum_mtu
bind_with_receive_buffer_size bind_with_receive_buffer_size
bind_with_socket_shards bind_with_socket_shards
from_std from_std
ping_timeout ping_timeout

blocking::RaknetSocket

需要 blocking。

方法 API 文档
send send
send_timeout send_timeout
send_with_order_channel send_with_order_channel
send_bytes send_bytes
send_bytes_timeout send_bytes_timeout
send_bytes_with_order_channel send_bytes_with_order_channel
send_batch send_batch
send_batch_timeout send_batch_timeout
send_batch_with_order_channel send_batch_with_order_channel
send_bytes_batch send_bytes_batch
send_bytes_batch_with_order_channel send_bytes_batch_with_order_channel
recv recv
recv_timeout recv_timeout
recv_bytes recv_bytes
recv_bytes_timeout recv_bytes_timeout
recv_batch recv_batch
recv_batch_timeout recv_batch_timeout
recv_bytes_batch recv_bytes_batch
flush flush
flush_timeout flush_timeout
close close
peer_addr peer_addr
local_addr local_addr
raknet_version raknet_version
mtu mtu
set_idle_maintenance set_idle_maintenance
set_send_options set_send_options
send_options send_options
set_recovery_options set_recovery_options
recovery_options recovery_options

blocking::RaknetListener

需要 blocking。

方法 API 文档
with_accept_backlog with_accept_backlog
with_idle_maintenance with_idle_maintenance
with_receive_batching with_receive_batching
listen listen
accept accept
accept_timeout accept_timeout
close close
local_addr local_addr
get_guid get_guid
set_full_motd set_full_motd
get_motd get_motd
get_peer_raknet_version get_peer_raknet_version

SendOptions

需要 send-policy。

方法 API 文档
with_in_flight_limits with_in_flight_limits
with_queue_budgets with_queue_budgets
with_flush_budget with_flush_budget
in_flight_frames in_flight_frames
in_flight_bytes in_flight_bytes
reliable_queue_bytes reliable_queue_bytes
unreliable_queue_bytes unreliable_queue_bytes
flush_bytes flush_bytes

导出与可用条件

  • Reliability:五种模式,见模式选择。
  • Bytes:重新导出的不可变字节缓冲区,用于拥有所有权的接口。
  • RecoveryOptions:公开字段 deadline_driven、tail_probe_min_delay、reset_backoff_on_progress,需要 recovery-policy。
  • SendOptions、SendOptionsError:需要 send-policy。
  • error::{RaknetError, Result} 与 blocking::{Error, Result}:不同的错误类型。
  • enable_raknet_log(u8) 及导出的 raknet_log_debug!、raknet_log_error!、raknet_log_info! 宏:进程日志控制。
  • bind_with_socket_shards、with_receive_batching:仅 Linux。
  • 策略方法需要相应 feature,同步包装还需要 blocking。
  • RaknetSocket::from 是供已协商且受分发器管理的连接使用的低层构造器,不代替常规 connect/accept,也不是 Sans-I/O。
  • 同步接口没有复制所有异步辅助方法,例如 set_loss_rate 和结构化 MOTD setter;以列表为准,不猜测包装方法名。

配置 · 错误 · 源码

Clone this wiki locally