Skip to content

Commit

Permalink
refactor: move the core functinality to the core module
Browse files Browse the repository at this point in the history
  • Loading branch information
niusia-ua committed Nov 15, 2024
1 parent b43ba4e commit 147da0b
Show file tree
Hide file tree
Showing 31 changed files with 21 additions and 16 deletions.
6 changes: 4 additions & 2 deletions src-tauri/src/commands/pattern.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{
core::{
parser::{self, PatternFormat},
pattern::{display::DisplaySettings, print::PrintSettings, PaletteItem, Pattern, PatternProject},
},
error::CommandResult,
parser::{self, PatternFormat},
pattern::{display::DisplaySettings, print::PrintSettings, PaletteItem, Pattern, PatternProject},
state::{AppStateType, PatternKey},
utils::path::app_document_dir,
};
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/core/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod parser;
pub mod pattern;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::io::Write;

use anyhow::Result;

use crate::pattern::PatternProject;
use crate::core::pattern::PatternProject;

pub fn parse_pattern(file_path: std::path::PathBuf) -> Result<PatternProject> {
log::info!("Parsing the EMBPROJ pattern file");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{bail, Result};
use quick_xml::events::Event;

use crate::pattern::PatternProject;
use crate::core::pattern::PatternProject;

use super::{
utils::{process_attributes, OxsVersion, Software},
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use quick_xml::{
};

use super::utils::*;
use crate::pattern::{display::DisplaySettings, print::PrintSettings, *};
use crate::core::pattern::{display::DisplaySettings, print::PrintSettings, *};

pub fn parse_pattern(file_path: std::path::PathBuf, software: Software) -> Result<PatternProject> {
log::trace!("OXS version is 1.0 in the {software:?} edition");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use byteorder::{LittleEndian, ReadBytesExt};
use ordered_float::NotNan;

use super::read::ReadXsdExt;
use crate::pattern::{display::*, print::*, *};
use crate::core::pattern::{display::*, print::*, *};

#[cfg(test)]
#[path = "xsd.test.rs"]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};

use super::partstitch::*;
use crate::pattern::Coord;
use crate::core::pattern::Coord;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
pub struct FullStitch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use borsh::{BorshDeserialize, BorshSerialize};
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};

use crate::pattern::Coord;
use crate::core::pattern::Coord;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
pub struct Line {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use borsh::{BorshDeserialize, BorshSerialize};
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};

use crate::pattern::Coord;
use crate::core::pattern::Coord;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
pub struct Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};

use super::fullstitch::*;
use crate::pattern::Coord;
use crate::core::pattern::Coord;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
pub struct PartStitch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use borsh::{BorshDeserialize, BorshSerialize};
use serde::{Deserialize, Serialize};

use super::{Line, Node};
use crate::pattern::Coord;
use crate::core::pattern::Coord;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
pub struct SpecialStitch {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src-tauri/src/events/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
use tauri::{AppHandle, Emitter, Listener, Manager, WebviewWindow};

use crate::{
pattern::{Stitch, StitchConflicts},
core::pattern::{Stitch, StitchConflicts},
state::{AppStateType, PatternKey},
};

Expand Down
7 changes: 4 additions & 3 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ mod error;

pub mod commands;
pub mod events;
pub mod logger;
pub mod parser;
pub mod pattern;
pub mod state;

pub mod core;
pub mod utils;

pub mod logger;
2 changes: 1 addition & 1 deletion src-tauri/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{collections::HashMap, path::PathBuf};
use borsh::{BorshDeserialize, BorshSerialize};
use serde::{Deserialize, Serialize};

use crate::pattern::PatternProject;
use crate::core::pattern::PatternProject;

#[derive(Debug, Hash, PartialEq, Eq, Clone, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
#[repr(transparent)]
Expand Down

0 comments on commit 147da0b

Please sign in to comment.