Reduce Boilerplate

This commit is contained in:
Chaoscaot
2023-04-24 19:04:44 +02:00
parent 25c4e97f71
commit eb84adb4a3
5 changed files with 80 additions and 171 deletions

View File

@@ -15,11 +15,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#[cfg(feature = "sql")]
use std::io::Cursor;
use std::path::PathBuf;
#[cfg(feature = "sql")]
use futures::executor::block_on;
use schemsearch_files::SchematicVersioned;
#[cfg(feature = "sql")]
use schemsearch_files::SpongeSchematic;
#[cfg(feature = "sql")]
use schemsearch_sql::{load_schemdata, SchematicNode};
@@ -46,9 +48,9 @@ pub struct SqlSchematicSupplier {
#[cfg(feature = "sql")]
impl SqlSchematicSupplier {
pub fn get_schematic(&self) -> Result<SchematicVersioned, String> {
pub fn get_schematic(&self) -> Result<SpongeSchematic, String> {
let mut schemdata = block_on(load_schemdata(self.node.id));
SchematicVersioned::load_data(&mut Cursor::new(schemdata.as_mut_slice()))
SpongeSchematic::load_data(&mut Cursor::new(schemdata.as_mut_slice()))
}
pub fn get_name(&self) -> String {