mirror of
https://github.com/Chaoscaot/schemsearch.git
synced 2025-11-05 05:54:02 +01:00
Reduce Boilerplate
This commit is contained in:
@ -39,7 +39,7 @@ use schemsearch_sql::load_all_schematics;
|
||||
#[cfg(feature = "sql")]
|
||||
use crate::types::SqlSchematicSupplier;
|
||||
use indicatif::*;
|
||||
use schemsearch_files::{SchematicVersioned};
|
||||
use schemsearch_files::SpongeSchematic;
|
||||
use crate::sinks::{OutputFormat, OutputSink};
|
||||
use crate::stderr::MaschineStdErr;
|
||||
|
||||
@ -206,7 +206,7 @@ fn main() {
|
||||
threshold: *matches.get_one::<f32>("threshold").expect("Couldn't get threshold"),
|
||||
};
|
||||
|
||||
let pattern = match SchematicVersioned::load(&PathBuf::from(matches.get_one::<String>("pattern").unwrap())) {
|
||||
let pattern = match SpongeSchematic::load(&PathBuf::from(matches.get_one::<String>("pattern").unwrap())) {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
cmd.error(ErrorKind::Io, format!("Error while loading Pattern: {}", e.to_string())).exit();
|
||||
@ -334,8 +334,8 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
fn load_schem(schem_path: &PathBuf) -> Option<SchematicVersioned> {
|
||||
match SchematicVersioned::load(schem_path) {
|
||||
fn load_schem(schem_path: &PathBuf) -> Option<SpongeSchematic> {
|
||||
match SpongeSchematic::load(schem_path) {
|
||||
Ok(x) => Some(x),
|
||||
Err(e) => {
|
||||
println!("Error while loading schematic ({}): {}", schem_path.to_str().unwrap(), e.to_string());
|
||||
|
||||
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user