pub struct Channel<'a> { /* private fields */ }Implementations§
Source§impl<'a> Channel<'a>
impl<'a> Channel<'a>
Sourcepub fn join(&self) -> Result<()>
pub fn join(&self) -> Result<()>
Join this channel
Examples found in repository?
examples/sender.rs (line 19)
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 18)
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 leave(&self) -> Result<()>
pub fn leave(&self) -> Result<()>
Leave this channel
Examples found in repository?
examples/sender.rs (line 31)
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 37)
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 rate_limit(&self, limit: u32) -> Result<()>
pub fn rate_limit(&self, limit: u32) -> Result<()>
Rate-limit sending 104857600 for 100 Mbps
Examples found in repository?
examples/sender.rs (line 22)
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}Sourcepub fn send(&self, data: &[u8]) -> Result<()>
pub fn send(&self, data: &[u8]) -> Result<()>
Send some multicast data
Examples found in repository?
examples/sender.rs (line 27)
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}Sourcepub fn receive(&self, buffer: &mut [u8]) -> Result<usize>
pub fn receive(&self, buffer: &mut [u8]) -> Result<usize>
Receive some multicast data
Examples found in repository?
examples/receiver.rs (line 22)
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<'a> Freeze for Channel<'a>
impl<'a> RefUnwindSafe for Channel<'a>
impl<'a> !Send for Channel<'a>
impl<'a> !Sync for Channel<'a>
impl<'a> Unpin for Channel<'a>
impl<'a> UnsafeUnpin for Channel<'a>
impl<'a> UnwindSafe for Channel<'a>
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