]>
code.octet-stream.net Git - m17rt/blob - m17app/src/tnc.rs
56cb6613e5be8f2b5f1834a87f13d21bc732763d
1 use std
::io
::{self, ErrorKind
, Read
, Write
};
3 use m17core
::tnc
::SoftTnc
;
6 pub trait Tnc
: Read
+ Write
+ Sized
{
7 fn try_clone(&mut self) -> Result
<Self, TncError
>;
8 fn start(&mut self) -> Result
<(), TncError
>;
9 fn close(&mut self) -> Result
<(), TncError
>;
17 // TODO: move the following to its own module
19 pub struct Soundmodem
{
21 config
: SoundmodemConfig
,
24 pub struct SoundmodemConfig
{
25 // sound cards, PTT, etc.
28 impl Read
for Soundmodem
{
29 fn read(&mut self, buf
: &mut [u8]) -> io
::Result
<usize> {
32 .map_err(|s
| io
::Error
::new(ErrorKind
::Other
, format
!("{:?}", s
)))
36 impl Write
for Soundmodem
{
37 fn write(&mut self, buf
: &[u8]) -> std
::io
::Result
<usize> {
40 .map_err(|s
| io
::Error
::new(ErrorKind
::Other
, format
!("{:?}", s
)))
43 fn flush(&mut self) -> std
::io
::Result
<()> {
48 impl Tnc
for Soundmodem
{
49 fn try_clone(&mut self) -> Result
<Self, TncError
> {
53 fn start(&mut self) -> Result
<(), TncError
> {
57 fn close(&mut self) -> Result
<(), TncError
> {