]> code.octet-stream.net Git - m17rt/blob - m17app/src/soundmodem.rs
Implement Tnc for TcpStream
[m17rt] / m17app / src / soundmodem.rs
1 use std::io::{self, ErrorKind, Read, Write};
2
3 use crate::tnc::{Tnc, TncError};
4 use m17core::tnc::SoftTnc;
5
6 pub struct Soundmodem {
7 tnc: SoftTnc,
8 config: SoundmodemConfig,
9 }
10
11 pub struct SoundmodemConfig {
12 // sound cards, PTT, etc.
13 }
14
15 impl Read for Soundmodem {
16 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
17 self.tnc
18 .read_kiss(buf)
19 .map_err(|s| io::Error::new(ErrorKind::Other, format!("{:?}", s)))
20 }
21 }
22
23 impl Write for Soundmodem {
24 fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
25 self.tnc
26 .write_kiss(buf)
27 .map_err(|s| io::Error::new(ErrorKind::Other, format!("{:?}", s)))
28 }
29
30 fn flush(&mut self) -> std::io::Result<()> {
31 Ok(())
32 }
33 }
34
35 impl Tnc for Soundmodem {
36 fn try_clone(&mut self) -> Result<Self, TncError> {
37 unimplemented!();
38 }
39
40 fn start(&mut self) -> Result<(), TncError> {
41 unimplemented!();
42 }
43
44 fn close(&mut self) -> Result<(), TncError> {
45 unimplemented!();
46 }
47 }