CRUD operations for named buffers stored per-project.
(
buffers: &DashMap<String, Buffer>,
name: &str,
content: &str,
description: Option<&str>,
)
| 18 | |
| 19 | /// CRUD operations for named buffers stored per-project. |
| 20 | pub fn create_buffer( |
| 21 | buffers: &DashMap<String, Buffer>, |
| 22 | name: &str, |
| 23 | content: &str, |
| 24 | description: Option<&str>, |
| 25 | ) -> Result<Buffer, String> { |
| 26 | let buf = Buffer { |
| 27 | name: name.to_string(), |
| 28 | content: content.to_string(), |
| 29 | description: description.map(|s| s.to_string()), |
| 30 | created_at: Utc::now(), |
| 31 | }; |
| 32 | buffers.insert(name.to_string(), buf.clone()); |
| 33 | Ok(buf) |
| 34 | } |
| 35 | |
| 36 | pub fn from_file( |
| 37 | buffers: &DashMap<String, Buffer>, |
no test coverage detected