Crate bitfold

Crate bitfold 

Source
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.
PacketInfo
Non-owning packet metadata used during processing.

Enums§

CompressionAlgorithm
Compression algorithm to use for packet data.
DeliveryGuarantee
Enum to specify how a packet should be delivered.
OrderingGuarantee
Enum to specify how a packet should be arranged.
PacketType
Id to identify a certain packet type.
SocketEvent
Events that can occur and are pushed through the event_receiver. These are user-facing events emitted by the socket/connection manager.