implement PartialEq, Eq and Hash derive traits
This commit is contained in:
parent
7efe73eb80
commit
a2d20dab8e
|
@ -22,4 +22,4 @@ getset = "0.1.2"
|
|||
serde = { version = "1.0.197", optional = true, features = ["derive"] }
|
||||
serde_json = "1.0.114"
|
||||
tracing = "0.1.40"
|
||||
zip = { version = "1.1.1", default-features = false, features = ["deflate", "time"], optional = true }
|
||||
zip = { version = "2.1.3", default-features = false, features = ["deflate", "time"], optional = true }
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::util::{
|
|||
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Execute {
|
||||
Align(String, Box<Execute>),
|
||||
Anchored(String, Box<Execute>),
|
||||
|
@ -365,7 +365,7 @@ fn combine_conditions_commands(
|
|||
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Condition {
|
||||
Atom(String),
|
||||
Not(Box<Condition>),
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::{
|
|||
|
||||
/// Represents a command that can be included in a function.
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Command {
|
||||
/// A command that is already formatted as a string.
|
||||
Raw(String),
|
||||
|
|
|
@ -13,7 +13,7 @@ use super::command::Command;
|
|||
|
||||
/// Function that can be called by a command
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone, Default, Getters)]
|
||||
#[derive(Debug, Clone, Default, Getters, PartialEq, Eq, Hash)]
|
||||
pub struct Function {
|
||||
commands: Vec<Command>,
|
||||
/// Name of the function
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::{
|
|||
|
||||
/// A Minecraft datapack.
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Datapack {
|
||||
// TODO: Support filter and overlays
|
||||
description: String,
|
||||
|
@ -107,17 +107,9 @@ impl Datapack {
|
|||
}
|
||||
|
||||
/// Compile the pack into a virtual folder.
|
||||
///
|
||||
/// The pack format in the compile options will be overridden by the pack format of the datapack.
|
||||
#[must_use]
|
||||
#[tracing::instrument(level = "debug", skip(self))]
|
||||
pub fn compile(&self, options: &CompileOptions) -> VFolder {
|
||||
let pack_formats = self
|
||||
.supported_formats
|
||||
.clone()
|
||||
.unwrap_or(self.pack_format..=self.pack_format);
|
||||
let options = &options.clone().with_pack_formats(pack_formats);
|
||||
|
||||
tracing::debug!("Compiling datapack: {:?}", self);
|
||||
|
||||
let compiler_state = Mutex::new(CompilerState::default());
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::{
|
|||
|
||||
/// Namespace of a datapack
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Namespace {
|
||||
name: String,
|
||||
functions: HashMap<String, Function>,
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
|||
|
||||
/// A tag for various types.
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Tag {
|
||||
replace: bool,
|
||||
values: Vec<TagValue>,
|
||||
|
@ -98,7 +98,7 @@ impl ToString for TagType {
|
|||
/// The value of a tag.
|
||||
#[allow(clippy::module_name_repetitions)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum TagValue {
|
||||
/// A simple value, either a resource location or an id of another tag.
|
||||
Simple(String),
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
//! Compile options for the compiler.
|
||||
|
||||
use std::{ops::RangeInclusive, sync::Mutex};
|
||||
use std::sync::Mutex;
|
||||
|
||||
use getset::Getters;
|
||||
|
||||
use crate::{datapack::Function, prelude::Datapack};
|
||||
use crate::datapack::Function;
|
||||
|
||||
use super::extendable_queue::ExtendableQueue;
|
||||
|
||||
|
@ -15,33 +15,19 @@ use super::extendable_queue::ExtendableQueue;
|
|||
pub struct CompileOptions {
|
||||
/// Whether to compile in debug mode.
|
||||
pub(crate) debug: bool,
|
||||
/// Pack format of the datapack.
|
||||
pub(crate) pack_formats: RangeInclusive<u8>,
|
||||
}
|
||||
|
||||
impl CompileOptions {
|
||||
/// Set whether to compile in debug mode.
|
||||
#[must_use]
|
||||
pub fn with_debug(self, debug: bool) -> Self {
|
||||
Self { debug, ..self }
|
||||
}
|
||||
|
||||
/// Set the pack format of the datapack.
|
||||
#[must_use]
|
||||
pub fn with_pack_formats(self, pack_formats: RangeInclusive<u8>) -> Self {
|
||||
Self {
|
||||
pack_formats,
|
||||
..self
|
||||
}
|
||||
Self { debug }
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for CompileOptions {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
debug: true,
|
||||
pack_formats: Datapack::LATEST_FORMAT..=Datapack::LATEST_FORMAT,
|
||||
}
|
||||
Self { debug: true }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use zip::ZipWriter;
|
|||
|
||||
/// Folder representation in virtual file system
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Default, Clone)]
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||
pub struct VFolder {
|
||||
folders: HashMap<String, VFolder>,
|
||||
files: HashMap<String, VFile>,
|
||||
|
@ -304,7 +304,7 @@ impl TryFrom<&Path> for VFolder {
|
|||
|
||||
/// File representation in virtual file system
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum VFile {
|
||||
/// Text file
|
||||
Text(String),
|
||||
|
|
Loading…
Reference in New Issue