changed name to reflect actual use of states io

This commit is contained in:
Nickiel12 2021-12-16 15:54:59 -08:00
parent 8fbc5be7d5
commit 48e2fbfd14
4 changed files with 12 additions and 12 deletions

View file

@ -1,6 +1,6 @@
pub mod message_handler; pub mod message_handler;
pub mod io_handler; pub mod states_io_handler;
pub mod stream_states { pub mod stream_states {
pub mod stream_states_class; pub mod stream_states_class;

View file

@ -3,15 +3,15 @@ use std::{sync::mpsc::{Sender, self, Receiver}, thread::{JoinHandle, self}};
use super::{message_handler::{MessageHandler, StateMessage}, stream_states::{enums::StateUpdate, stream_states_class::StreamState}}; use super::{message_handler::{MessageHandler, StateMessage}, stream_states::{enums::StateUpdate, stream_states_class::StreamState}};
pub struct IOHandler { pub struct StatesIOHandler {
pub listener_join_handler: Option<JoinHandle<()>>, pub listener_join_handler: Option<JoinHandle<()>>,
pub message_thread_tx: Option<Sender<StateMessage>>, pub message_thread_tx: Option<Sender<StateMessage>>,
data_rx: Option<Receiver<StreamState>>, data_rx: Option<Receiver<StreamState>>,
} }
impl IOHandler { impl StatesIOHandler {
pub fn new() -> Self { pub fn new() -> Self {
IOHandler{ StatesIOHandler{
..Default::default() ..Default::default()
} }
} }
@ -71,9 +71,9 @@ impl IOHandler {
} }
} }
impl Default for IOHandler { impl Default for StatesIOHandler {
fn default() -> Self { fn default() -> Self {
IOHandler { StatesIOHandler {
message_thread_tx: None, message_thread_tx: None,
listener_join_handler: None, listener_join_handler: None,
data_rx: None, data_rx: None,

View file

@ -7,4 +7,4 @@ pub mod stream_states_tests;
#[cfg(test)] #[cfg(test)]
pub mod message_handler_tests; pub mod message_handler_tests;
#[cfg(test)] #[cfg(test)]
pub mod io_handler_tests; pub mod states_io_handler_tests;

View file

@ -1,12 +1,12 @@
use std::thread; use std::thread;
use crate::modules::{io_handler::{IOHandler}, message_handler::{MessageHandler, StateMessage}, stream_states::{stream_states_class::StreamState, enums::StateUpdate}}; use crate::modules::{states_io_handler::{StatesIOHandler}, message_handler::{MessageHandler, StateMessage}, stream_states::{stream_states_class::StreamState, enums::StateUpdate}};
#[test] #[test]
fn test_make_socket() { fn test_make_socket() {
let state = StreamState::new(); let state = StreamState::new();
let mut io_handler = IOHandler::new(); let mut io_handler = StatesIOHandler::new();
io_handler.start_socket_listener(state, "no-one cares"); io_handler.start_socket_listener(state, "no-one cares");
@ -23,7 +23,7 @@ fn test_make_socket() {
#[test] #[test]
fn send_on_multiple_threads() { fn send_on_multiple_threads() {
let state = StreamState::new(); let state = StreamState::new();
let mut io_handler = IOHandler::new(); let mut io_handler = StatesIOHandler::new();
io_handler.start_socket_listener(state, "no-one cares"); io_handler.start_socket_listener(state, "no-one cares");
@ -54,7 +54,7 @@ fn send_on_multiple_threads() {
#[test] #[test]
#[should_panic] #[should_panic]
fn io_handler_not_started_1() { fn io_handler_not_started_1() {
let io_handler = IOHandler::new(); let io_handler = StatesIOHandler::new();
let state = io_handler.get_states(); let state = io_handler.get_states();
} }
@ -62,7 +62,7 @@ fn io_handler_not_started_1() {
#[test] #[test]
#[should_panic] #[should_panic]
fn io_handler_not_started_2() { fn io_handler_not_started_2() {
let io_handler = IOHandler::new(); let io_handler = StatesIOHandler::new();
let state = io_handler.close(); let state = io_handler.close();
} }