libutils_console/
continuations.rs1use alloc::{
7 string::{
8 String,
9 ToString
10 },
11 vec::Vec
12};
13
14use libutils_issue::{
16 Issue,
17 Severity
18};
19
20
21#[must_use]
27pub trait Synchronization: Sized {
28 fn sync(self) -> ();
29 fn ignore(self) -> () {}
30}
31
32#[must_use]
34pub trait Descriptor: Sized {
35 fn metadata(&self) -> Result<impl Data, Issue>;
36 fn read_bytes(&mut self) -> Result<Vec<u8>, Issue>;
37 fn read(&mut self) -> Result<String, Issue> {return String::from_utf8(self.read_bytes()?).map_err(|error| Issue {
38 name: "Error encoding file to UTF-8",
39 description: Some(error.to_string()),
40 severity: Severity::Error
41 })}
42 fn write_bytes(&mut self, content: &[u8]) -> Result<(), Issue>;
43 fn write(&mut self, content: &str) -> Result<(), Issue> {return self.write_bytes(content.as_bytes())}
44 fn close(self) -> () {}
45}
46
47#[must_use]
49pub trait Data: Sized {
50 fn size(&self) -> usize;
51}