rs-tftpd/src/worker.rs
2023-03-07 20:12:42 +03:00

27 lines
643 B
Rust

use std::{
error::Error,
net::{SocketAddr, UdpSocket},
path::Path,
};
use crate::packet::Option;
pub struct Worker {
socket: UdpSocket,
}
impl Worker {
pub fn new(addr: SocketAddr, remote: SocketAddr) -> Result<Worker, Box<dyn Error>> {
let socket = UdpSocket::bind(SocketAddr::from((addr.ip(), 0)))?;
socket.connect(remote)?;
Ok(Worker { socket })
}
pub fn send_file(&self, file: &Path, options: &Vec<Option>) -> Result<(), Box<dyn Error>> {
Ok(())
}
pub fn receive_file(&self, file: &Path, options: &Vec<Option>) -> Result<(), Box<dyn Error>> {
Ok(())
}
}