Expand description
Bitfold: a small public API facade for the workspace.
This crate provides a clean, stable surface that re-exports the most commonly used types to build reliable UDP apps:
- Host and events (
Host,SocketEvent) - Packet types and guarantees (
Packet,DeliveryGuarantee, …) - Core configuration (
Config)
Example
ⓘ
use bitfold::{Host, SocketEvent, Packet, DeliveryGuarantee, OrderingGuarantee};
let mut host = Host::bind_any().unwrap();
let remote = host.local_addr().unwrap();
// Send a reliable, unordered packet to ourselves
let pkt = Packet::reliable_unordered(remote, b"hello".to_vec());
host.send(pkt).unwrap();
// Poll once
use std::time::Instant;
host.manual_poll(Instant::now());
if let Some(SocketEvent::Packet(rx)) = host.recv() {
assert_eq!(rx.payload(), b"hello");
}Re-exports§
pub use crate::core::config::CompressionAlgorithm;pub use crate::core::config::Config;pub use crate::host::Host;pub use crate::host::SocketEvent;pub use crate::protocol::packet::DeliveryGuarantee;pub use crate::protocol::packet::OrderingGuarantee;pub use crate::protocol::packet::Packet;pub use crate::protocol::packet::PacketInfo;pub use crate::protocol::packet::PacketType;
Modules§
- core
- Core foundational types and utilities.
- host
- Host socket and session manager for transport and peer coordination.
- peer
- Peer state machine for managing remote endpoints.
- prelude
- Convenience prelude with the most commonly used items.
- protocol
- Protocol packet types, headers, and protocol logic.
- utilities
- Utility functions for Bitfold networking.