ilovetv/src/lib.rs

43 lines
1.1 KiB
Rust
Raw Normal View History

mod m3u8;
mod parser;
use std::io::{stdin, stdout, Stdin, StdoutLock, Write};
pub use m3u8::M3u8;
pub use parser::Parser;
mod config;
pub use config::Configuration;
2023-01-18 21:23:04 +01:00
mod downloader;
2023-01-19 01:22:29 +01:00
pub use downloader::download_with_progress;
2023-01-19 01:39:50 +01:00
pub struct Readline<'a> {
stdout: StdoutLock<'a>,
stdin: Stdin,
}
impl<'a> Readline<'a> {
pub fn new() -> Self {
Self {
stdout: stdout().lock(),
stdin: stdin(),
}
}
pub fn input(&mut self, toprint: &str) -> String {
print!("{}", toprint);
self.stdout.flush().unwrap();
let mut buffer = String::new();
self.stdin.read_line(&mut buffer).unwrap();
buffer
2023-01-19 01:39:50 +01:00
}
}
2023-02-28 16:22:53 +01:00
/**
* I know that this isn't considered true rusty code, but the places it's used in is
* safe. For this I'll leave the funciton as unsafe, so to better see it's uses.
2023-02-28 16:22:53 +01:00
* This solution makes the uses BLAZINGLY FAST which moreover is the most rusty you can get.
*/
pub unsafe fn get_mut_ref<T>(reference: &T) -> &mut T {
let ptr = reference as *const T as *mut T;
&mut *ptr
}