Crate lyanne

source ·
Expand description

Efficient, tick-oriented communication framework for server-client architectures.

Lyanne is an abstraction for communication between client and server, greatly simplifying the process, maintaining low latency and low resource usage.

Moves the most resource-intensive work to asynchronous operations, but both client and server calls, such as sending/receiving packets, can be used in synchronous contexts.

Being highly customizable, Lyanne supports:

  • Multiple runtimes.
  • Different ways of serializing/deserializing packages.
  • Different authenticators, including the required/optional use of tls with rustls.

All within features, keeping compilation time fast.

§Examples

Adding lyanne dependency in server:

[dependencies]
lyanne = { version = "0.3", features = [
    "rt_smol", # We need one runtime.
    "sd_bincode", # Serde + Bincode will help our packet serialization/deserialization.
    "server", # Server exclusive feature.
] }

# Our runtime.
smol = "^2.0.0"

# Our serializer.
serde = { version = "^1.0.0", features = ["derive"] }
bincode = "^1.0.0"

Adding lyanne dependency in client:

[dependencies]
lyanne = { version = "0.3", features = [
    # ...
    "client", # Same as the server, but using "client" instead of "server".
] }

Creating packets with sd_bincode:

use lyanne::packets::Packet;
use serde::{Deserialize, Serialize};

#[derive(Packet, Deserialize, Serialize, Debug)]
struct HelloPacket {
    player_name: String,
}

#[derive(Packet, Deserialize, Serialize, Debug)]
struct MessagePacket {
    message: String,
}

Modules§

  • Client exclusive module.
  • Module related to the messaging by the client and server.
  • Packets are the sets of data that are transferred over the network, represented by structs.
  • Server exclusive module.

Macros§

Structs§