From 2875da07e13bf7a42defc453f4aecc447a2f8004 Mon Sep 17 00:00:00 2001 From: Marrub Date: Sat, 30 Mar 2019 17:19:10 -0400 Subject: [PATCH] move text from durandal to marathon --- source/durandal.rs | 1 - source/durandal/bin.rs | 12 ++---------- source/marathon.rs | 1 + source/marathon/map.rs | 4 ++-- source/marathon/shp.rs | 4 ++-- source/{durandal => marathon}/text.rs | 8 ++++---- source/marathon/trm.rs | 2 +- source/marathon/wad.rs | 4 ++-- 8 files changed, 14 insertions(+), 22 deletions(-) rename source/{durandal => marathon}/text.rs (96%) diff --git a/source/durandal.rs b/source/durandal.rs index a2b8adf..c7fc605 100644 --- a/source/durandal.rs +++ b/source/durandal.rs @@ -15,6 +15,5 @@ pub mod file; pub mod fixed; pub mod image; pub mod sound; -pub mod text; // EOF diff --git a/source/durandal/bin.rs b/source/durandal/bin.rs index e5124a5..d8ee0d6 100644 --- a/source/durandal/bin.rs +++ b/source/durandal/bin.rs @@ -1,6 +1,6 @@ //! Binary data conversion utilities. -use crate::durandal::{err::*, text::mac_roman_conv}; +use crate::durandal::err::*; use std::{fmt, num::NonZeroU16}; #[doc(hidden)] @@ -489,14 +489,6 @@ impl fmt::Debug for OptU16 } } -impl fmt::Debug for Ident -{ - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result - { - write!(f, "\"{}\"", mac_roman_conv(&self.0)) - } -} - impl PartialEq<[u8; 4]> for Ident { #[inline] @@ -528,7 +520,7 @@ impl<'a> PartialEq<&'a [u8; 4]> for Ident /// assert_eq!(&Ident(*b"POLY"), *b"POLY"); /// assert_eq!(&Ident(*b"POLY"), b"POLY"); /// ``` -#[derive(Clone, Copy, Default, Eq, PartialEq)] +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize, serde::Deserialize))] pub struct Ident(/** The individual bytes of this identifier. */ pub [u8; 4]); diff --git a/source/marathon.rs b/source/marathon.rs index dde7ee7..d01f3c6 100644 --- a/source/marathon.rs +++ b/source/marathon.rs @@ -8,6 +8,7 @@ pub mod pict; pub mod ppm; pub mod shp; pub mod snd; +pub mod text; pub mod tga; pub mod trm; pub mod wad; diff --git a/source/marathon/map.rs b/source/marathon/map.rs index 461d2af..3e65cf1 100644 --- a/source/marathon/map.rs +++ b/source/marathon/map.rs @@ -1,7 +1,7 @@ //! Structures used by Marathon's Map format. -use crate::{durandal::{bin::*, err::*, fixed::*, text::*}, - marathon::xfer::TransferMode}; +use crate::{durandal::{bin::*, err::*, fixed::*}, + marathon::{text::*, xfer::TransferMode}}; use bitflags::bitflags; /// Reads a `LightFunc` object. diff --git a/source/marathon/shp.rs b/source/marathon/shp.rs index a387234..9ecb3cf 100644 --- a/source/marathon/shp.rs +++ b/source/marathon/shp.rs @@ -1,7 +1,7 @@ //! Marathon Shapes format handling. -use crate::{durandal::{bin::*, err::*, fixed::*, image::*, text::*}, - marathon::xfer::TransferMode}; +use crate::{durandal::{bin::*, err::*, fixed::*, image::*}, + marathon::{text::*, xfer::TransferMode}}; use bitflags::bitflags; /// Reads a color from a color table into `clut`. diff --git a/source/durandal/text.rs b/source/marathon/text.rs similarity index 96% rename from source/durandal/text.rs rename to source/marathon/text.rs index 375b193..fc41163 100644 --- a/source/durandal/text.rs +++ b/source/marathon/text.rs @@ -5,7 +5,7 @@ /// # Examples /// /// ``` -/// use maraiah::durandal::text::to_binsize; +/// use maraiah::marathon::text::to_binsize; /// /// assert_eq!(to_binsize(5000), "5kB".to_string()); /// ``` @@ -57,7 +57,7 @@ pub fn fuck_string(s: &[u8]) -> Vec /// # Examples /// /// ``` -/// use maraiah::durandal::text::pascal_str; +/// use maraiah::marathon::text::pascal_str; /// /// assert_eq!(pascal_str(b"\x0bhello world"), b"hello world"[..].into()); /// assert_eq!(pascal_str(b"\x0chello world"), None); @@ -74,7 +74,7 @@ pub fn pascal_str(b: &[u8]) -> Option<&[u8]> /// # Examples /// /// ``` -/// use maraiah::durandal::text::mac_roman_conv; +/// use maraiah::marathon::text::mac_roman_conv; /// /// assert_eq!(mac_roman_conv(b"p\x8cth"), "påth"); /// assert_eq!(mac_roman_conv(b"I\xd5ve"), "I’ve"); @@ -99,7 +99,7 @@ pub fn mac_roman_conv(s: &[u8]) -> String /// # Examples /// /// ``` -/// use maraiah::durandal::text::mac_roman_cstr; +/// use maraiah::marathon::text::mac_roman_cstr; /// /// assert_eq!(mac_roman_cstr(b"I\xd5ve awaken\0ed"), "I’ve awaken"); /// assert_eq!(mac_roman_cstr(b"I\xd5ve awaken\0"), "I’ve awaken"); diff --git a/source/marathon/trm.rs b/source/marathon/trm.rs index 5e7edc4..3181dec 100644 --- a/source/marathon/trm.rs +++ b/source/marathon/trm.rs @@ -1,6 +1,6 @@ //! Structures used by Marathon's Map format's terminal definitions. -use crate::durandal::{bin::*, err::*, text::*}; +use crate::{durandal::{bin::*, err::*}, marathon::text::*}; use bitflags::bitflags; /// Reads an `InterGroup`. diff --git a/source/marathon/wad.rs b/source/marathon/wad.rs index cdd64fe..a45830b 100644 --- a/source/marathon/wad.rs +++ b/source/marathon/wad.rs @@ -1,7 +1,7 @@ //! Marathon Wad format handling. -use crate::{durandal::{bin::*, err::*, image, text::mac_roman_cstr}, - marathon::{map, phy, pict, trm}}; +use crate::{durandal::{bin::*, err::*, image}, + marathon::{map, phy, pict, text::mac_roman_cstr, trm}}; use std::collections::BTreeMap; /// Reads all chunks in an entry.