pub struct Librecast { /* private fields */ }Implementations§
Source§impl Librecast
impl Librecast
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new librecast context
Examples found in repository?
examples/sender.rs (line 8)
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}More examples
examples/receiver.rs (line 8)
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 .build()?;
16
17 // Join the channel
18 channel.join()?;
19
20 // Receive a message
21 let mut buffer = vec![0u8; 1024]; // Buffer to hold received data
22 match channel.receive(&mut buffer) {
23 Ok(size) => {
24 // Process the received data
25 let received_data = &buffer[..size];
26 println!(
27 "Received data: {:?}",
28 String::from_utf8_lossy(received_data)
29 );
30 }
31 Err(e) => {
32 eprintln!("Failed to receive data: {}", e);
33 }
34 }
35
36 // Leave the channel
37 channel.leave()?;
38
39 Ok(())
40}Sourcepub fn channel_builder(&self) -> ChannelBuilder<'_>
pub fn channel_builder(&self) -> ChannelBuilder<'_>
Get a builder for creating a new channel
Examples found in repository?
examples/sender.rs (line 12)
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}More examples
examples/receiver.rs (line 12)
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 .build()?;
16
17 // Join the channel
18 channel.join()?;
19
20 // Receive a message
21 let mut buffer = vec![0u8; 1024]; // Buffer to hold received data
22 match channel.receive(&mut buffer) {
23 Ok(size) => {
24 // Process the received data
25 let received_data = &buffer[..size];
26 println!(
27 "Received data: {:?}",
28 String::from_utf8_lossy(received_data)
29 );
30 }
31 Err(e) => {
32 eprintln!("Failed to receive data: {}", e);
33 }
34 }
35
36 // Leave the channel
37 channel.leave()?;
38
39 Ok(())
40}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Librecast
impl RefUnwindSafe for Librecast
impl !Sync for Librecast
impl Unpin for Librecast
impl UnsafeUnpin for Librecast
impl UnwindSafe for Librecast
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more