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 bitfold_core as core;pub use bitfold_host as host;pub use bitfold_peer as peer;pub use bitfold_protocol as protocol;
Modules§
- prelude
- Convenience prelude with the most commonly used items.
- utilities
- Utility functions for DNS resolution and IP operations. Utility functions for Bitfold networking.
Structs§
- Config
- Configuration options to tune protocol and runtime behavior.
- Host
- High-level host for managing connections and sending/receiving packets.
- Packet
- User-friendly packet containing payload, endpoint, and guarantees.
- Packet
Info - Non-owning packet metadata used during processing.
Enums§
- Compression
Algorithm - Compression algorithm to use for packet data.
- Delivery
Guarantee - Enum to specify how a packet should be delivered.
- Ordering
Guarantee - Enum to specify how a packet should be arranged.
- Packet
Type - Id to identify a certain packet type.
- Socket
Event - Events that can occur and are pushed through the event_receiver. These are user-facing events emitted by the socket/connection manager.