From a77e68b5540a5d0a105184b947a795ebee3f138a Mon Sep 17 00:00:00 2001 From: G2-Games Date: Sat, 4 May 2024 16:29:56 -0500 Subject: [PATCH] Added utils for binary utilities --- Cargo.toml | 9 ++++++++- cz/Cargo.toml | 4 ++++ cz/src/common.rs | 4 ++-- cz/src/lib.rs | 4 ++++ utils/Cargo.toml | 9 +++++++++ utils/src/main.rs | 10 ++++++++++ 6 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 utils/Cargo.toml create mode 100644 utils/src/main.rs diff --git a/Cargo.toml b/Cargo.toml index baa7ece..31eb562 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,12 @@ [workspace] - +resolver = "2" members = [ "cz", + "utils", ] + +[workspace.package] +authors = ["G2"] + +[workspace.lints.rust] +unsafe_code = "forbid" diff --git a/cz/Cargo.toml b/cz/Cargo.toml index 890f027..f9d4df2 100644 --- a/cz/Cargo.toml +++ b/cz/Cargo.toml @@ -2,6 +2,10 @@ name = "cz" version = "0.1.0" edition = "2021" +description=""" +A encoder/decoder for CZ# image files used in +[RealLive Engine](https://www.pcgamingwiki.com/wiki/Engine:RealLive). +""" [dependencies] image = "0.25" diff --git a/cz/src/common.rs b/cz/src/common.rs index 6114e9f..7ab08b2 100644 --- a/cz/src/common.rs +++ b/cz/src/common.rs @@ -1,7 +1,7 @@ //! Shared types and traits between CZ# files use std::{ - io::{self, Cursor, Read, Seek, Write}, path::PathBuf + io::{self, Read, Seek, Write}, path::PathBuf }; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; @@ -133,7 +133,7 @@ impl CzHeader for CommonHeader { pub trait CzImage { type Header; - /// Create a [CZImage] from bytes + /// Create a [crate::CzImage] from bytes fn decode(bytes: &mut T) -> Result where Self: Sized; diff --git a/cz/src/lib.rs b/cz/src/lib.rs index c5d6250..3529899 100644 --- a/cz/src/lib.rs +++ b/cz/src/lib.rs @@ -6,9 +6,13 @@ pub mod formats { pub mod cz3; } +#[doc(inline)] pub use formats::cz0::Cz0Image; +#[doc(inline)] pub use formats::cz1::Cz1Image; +#[doc(inline)] pub use formats::cz3::Cz3Image; /// Traits for CZ# images +#[doc(inline)] pub use common::CzImage; diff --git a/utils/Cargo.toml b/utils/Cargo.toml new file mode 100644 index 0000000..e0dddd0 --- /dev/null +++ b/utils/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "utils" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +cz = { path = "../cz" } diff --git a/utils/src/main.rs b/utils/src/main.rs new file mode 100644 index 0000000..686cb69 --- /dev/null +++ b/utils/src/main.rs @@ -0,0 +1,10 @@ +use std::fs; + +use cz::{Cz3Image, CzImage}; + +fn main() { + let mut input = fs::File::open("../../test_files/Old_TestFiles/129.CZ3").unwrap(); + let img_file = Cz3Image::decode(&mut input).unwrap(); + + img_file.save_as_png("test1.png").unwrap(); +}