Skip to content

Commit

Permalink
cod
Browse files Browse the repository at this point in the history
  • Loading branch information
ethteck committed Dec 4, 2023
0 parents commit 2cef65b
Show file tree
Hide file tree
Showing 9 changed files with 502 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on:
release:
types: [created]
jobs:
release:
name: release ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-gnu
archive: zip
- target: x86_64-unknown-linux-musl
archive: tar.gz
- target: x86_64-apple-darwin
archive: zip
steps:
- uses: actions/checkout@master
- name: Compile and release
uses: rust-build/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
RUSTTARGET: ${{ matrix.target }}
ARCHIVE_TYPES: ${{ matrix.archive }}
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CRATE_AUTH_TOKEN }}
38 changes: 38 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Rust

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
rustfmt-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run cargo fmt
run: cargo fmt --all -- --check
- name: Run cargo clippy
run: cargo clippy --all -- -D warnings
macos-check:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Test
run: cargo test --all-features
ubuntu-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Test
run: cargo test --all-features
windows-check:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Test
run: cargo test --all-features
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}
244 changes: 244 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "crunch64"
version = "0.1.0"
edition = "2021"
description = "A library for handling common compression formats for N64 games"
repository = "https://github.com/ethteck/crunch64"
license = "MIT"

[dependencies]
clap = { version = "4.4.10", features = ["derive"] }
thiserror = "1.0"
37 changes: 37 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pub mod yay0;

use thiserror::Error;
use yay0::{compress_yay0, decompress_yay0};

#[derive(Copy, Clone, Debug, Error, PartialEq, Eq, Hash)]
pub enum Crunch64Error {
#[error("Failed to open file")]
OpenFile,
#[error("Failed to read file")]
ReadFile,
#[error("Failed to write file")]
WriteFile,
}

#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum CompressionType {
Yay0,
Yaz0,
}

impl CompressionType {
pub fn decompress(self: CompressionType, bytes: Vec<u8>) -> Vec<u8> {
match self {
CompressionType::Yay0 => decompress_yay0(bytes),
_ => panic!("Unsupported compression type: {:?}", self),
}
}

pub fn compress(self: CompressionType, bytes: Vec<u8>) -> Vec<u8> {
match self {
CompressionType::Yay0 => compress_yay0(bytes),
_ => panic!("Unsupported compression type: {:?}", self),
}
}
}
Loading

0 comments on commit 2cef65b

Please sign in to comment.