sender/sender.rs
1// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
2// Copyright (c) 2025 Gavin Henry <ghenry@sentrypeer.org>
3
4use librecast::Librecast;
5
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 // Create a new librecast context
8 let librecast = Librecast::new()?;
9
10 // Create a channel using the builder pattern
11 let channel = librecast
12 .channel_builder()
13 .name("example-channel")
14 .enable_raptorq()
15 .enable_loopback()
16 .build()?;
17
18 // Join the channel
19 channel.join()?;
20
21 // Rate limits the channel to 100Mbps
22 channel.rate_limit(104857600)?;
23
24 // Send a message
25 let data = b"Hello, Librecast!";
26 channel
27 .send(data)
28 .expect("Failed to send data on the channel");
29
30 // Leave the channel
31 channel.leave()?;
32
33 Ok(())
34}