-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efd0a5a
commit 6ccba6d
Showing
20 changed files
with
455 additions
and
694 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ members = [ | |
"tools/netzwerker", | ||
"tools/rist-io", | ||
] | ||
resolver = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
use std::io; | ||
|
||
use rist_rs_std::StdRuntime; | ||
use rist_rs_types::traits::{ | ||
protocol::{Ctl, Protocol, ProtocolEvent, IOV}, | ||
runtime::Runtime, | ||
}; | ||
|
||
#[derive(Clone, Debug)] | ||
struct SimpleCtl; | ||
|
||
impl Ctl for SimpleCtl { | ||
type Error = io::Error; | ||
|
||
type Output = (); | ||
|
||
fn start() -> Self { | ||
todo!() | ||
} | ||
|
||
fn shutdown() -> Self { | ||
todo!() | ||
} | ||
} | ||
|
||
struct Server {} | ||
|
||
impl Server { | ||
fn new() -> Self { | ||
Self {} | ||
} | ||
} | ||
|
||
impl<R> Protocol<R> for Server | ||
where | ||
R: Runtime, | ||
{ | ||
type Ctl = SimpleCtl; | ||
|
||
fn run(&mut self, rt: &mut R, iov: &[IOV<R, Self::Ctl>]) -> ProtocolEvent<R> { | ||
let mut buf = [0u8; 1500]; | ||
for ev in iov { | ||
match ev { | ||
IOV::Readable(socket) => match rt.recv_from(*socket, &mut buf) { | ||
Err(err) => tracing::error!(?err, "recv_from"), | ||
Ok((len, addr)) => { | ||
let packet = buf.split_at(len).0; | ||
if let Err(err) = rt.send_to(*socket, packet, addr) { | ||
tracing::error!(?err, "send_to") | ||
} | ||
} | ||
}, | ||
IOV::Writeable(_) => {} | ||
IOV::Error(socket, err) => { | ||
tracing::error!(?socket, ?err, "error"); | ||
} | ||
IOV::Ctl(_) => todo!(), | ||
IOV::Empty => todo!(), | ||
} | ||
} | ||
ProtocolEvent::asap(&rt.get_default_clock()) | ||
} | ||
} | ||
|
||
fn main() { | ||
let rt = StdRuntime::new(); | ||
rt.run(Server::new()); | ||
} |
Oops, something went wrong.