1pub mod audio;
4pub mod console;
6pub mod io;
8
9pub mod prelude;
10pub mod time;
12pub mod window;
14
15pub mod collections;
17pub mod decoders;
19mod parsers;
21mod slice;
22
23mod mem;
25
26pub mod gui;
27
28mod iterators;
30
31pub mod math;
33
34pub mod ogl;
36
37pub mod text_writer;
39
40#[cfg(feature="net")]
42pub mod net;
43
44#[cfg(feature = "extras")]
47pub mod extras;
48
49use glow::Context;
50use std::{cell::RefCell, ops::Deref, rc::Rc, sync::Arc};
51
52pub type GlowGL = Arc<Box<Context>>;
54
55pub struct FlufflState<T> {
56 inner: Rc<RefCell<T>>,
57}
58impl<T> Clone for FlufflState<T> {
59 fn clone(&self) -> Self {
60 Self {
61 inner: self.inner.clone(),
62 }
63 }
64}
65impl<T> FlufflState<T> {
66 pub fn new(state: T) -> Self {
67 Self {
68 inner: Rc::new(RefCell::new(state)),
69 }
70 }
71}
72
73impl<T> Deref for FlufflState<T> {
74 type Target = Rc<RefCell<T>>;
75 fn deref(&self) -> &Self::Target {
76 &self.inner
77 }
78}
79
80#[derive(Debug)]
81pub enum FlufflError {
83 GenericError(String),
84 FromUtf8ParseError(String),
85 WindowInitError(String),
86 IOError(String),
87}
88
89impl From<std::io::Error> for FlufflError {
90 fn from(err: std::io::Error) -> Self {
91 FlufflError::IOError(err.to_string())
92 }
93}
94
95impl From<std::string::FromUtf8Error> for FlufflError {
96 fn from(err: std::string::FromUtf8Error) -> Self {
97 Self::FromUtf8ParseError(err.to_string())
98 }
99}