1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use std::fmt;
use crate::engine::d2::{
asset::{Asset, File},
util::{Disposable, Value},
};
use super::BasicAsset;
pub struct BasicFile {
pub inner: BasicAsset<BasicFile>,
content: Option<String>,
}
impl BasicFile {
pub fn new(content: Option<String>) -> Self {
Self {
inner: BasicAsset::new(),
content,
}
}
fn copy_from(&mut self, that: BasicFile) {
self.content = that.content;
}
fn on_disposed(&mut self) {
self.content = None;
}
}
impl AsRef<BasicAsset<BasicFile>> for BasicFile {
fn as_ref(&self) -> &BasicAsset<BasicFile> {
&self.inner
}
}
impl File for BasicFile {}
impl Asset for BasicFile {
fn reload_count(&self) -> usize {
self.inner.reload_count()
}
}
impl Disposable for BasicFile {
fn dispose(&self) {
self.inner.dispose()
}
}
impl fmt::Display for BasicFile {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.inner.assert_not_disposed();
write!(
f,
"{}",
self.content.clone().unwrap_or(String::from("None"))
)
}
}
impl fmt::Debug for BasicFile {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BasicFile")
.finish()
}
}