Skip to content

Commit

Permalink
version: bump to 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
roccodev committed Apr 5, 2024
1 parent 030b5af commit a9f64c7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bdat"
version = "0.5.0-alpha.1"
version = "0.5.0"
description = "(De)serialization library for Monolithsoft's BDAT file format"
authors = ["RoccoDev <[email protected]>"]
edition = "2021"
Expand All @@ -12,7 +12,7 @@ exclude = ["/.vscode", "/.github"]

[dependencies]
serde = { version = "1.0", optional = true, features = ["derive"] }
byteorder = "1.4"
byteorder = "1.5"
thiserror = "1.0"
enum-kinds = "0.5.1"
num_enum = "0.7.2"
Expand Down
2 changes: 2 additions & 0 deletions src/io/detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ use crate::legacy::read::{LegacyBytes, LegacyReader};
use crate::modern::FileReader;
use crate::{BdatVersion, LegacyVersion, SwitchEndian, WiiEndian};

/// Compatibility file reader returned by [`bdat::from_reader`](`crate::from_reader`)
pub enum VersionReader<R: Read + Seek> {
LegacyWii(LegacyReader<R, WiiEndian>),
LegacySwitch(LegacyReader<R, SwitchEndian>),
Modern(FileReader<BdatReader<R, SwitchEndian>, SwitchEndian>),
}

/// Compatibility slice reader returned by [`bdat::from_bytes`](`crate::from_bytes`)
pub enum VersionSlice<'b> {
LegacyWii(LegacyBytes<'b, WiiEndian>),
LegacySwitch(LegacyBytes<'b, SwitchEndian>),
Expand Down
8 changes: 4 additions & 4 deletions src/io/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ pub struct BdatSlice<'b, E> {
_endianness: PhantomData<E>,
}

/// Table extractor from a BDAT file.
///
/// ## Notice
/// In future versions, this may be replaced by a common file struct.
pub trait BdatFile<'b> {
/// The output table type
type TableOut;

/// Reads all tables from the BDAT source.
///
/// ## Future compatibility
/// This function might start returning an iterator when Rust 1.75.0
/// hits stable (specifically [this issue](https://github.com/rust-lang/rust/issues/91611)).
fn get_tables(&mut self) -> Result<Vec<Self::TableOut>>;

/// Returns the number of tables in the BDAT file.
Expand Down
1 change: 1 addition & 0 deletions src/table/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub enum Cell<'b> {
ValueType,
derive(TryFromPrimitive),
repr(u8),
doc = "Discriminants for [`Value`], generated automatically.",
cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize)),
cfg_attr(feature = "serde", serde(into = "u8", try_from = "u8"))
)]
Expand Down
8 changes: 8 additions & 0 deletions src/table/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ impl<'t, 'buf> CompatColumnRef<'t, 'buf> {
}

impl<'b> CompatRow<'b> {
/// Returns an iterator over this row's cells.
///
/// Because this is a compatibility wrapper, the returned [`Cell`]s must be owned
/// (and therefore cloned), as modern tables do not store cells directly.
pub fn cells(&self) -> impl Iterator<Item = Cell<'b>> + '_ {
match self {
CompatRow::Modern(m) => {
Expand All @@ -457,6 +461,10 @@ impl<'b> CompatRow<'b> {
}
}

/// Returns an iterator over this row's cells, taking ownership of the row.
///
/// Unlike the [borrowed variant](CompatRow::cells), this iterator moves instead of cloning.
/// In the case of modern tables, the moved value is wrapped.
pub fn into_cells(self) -> impl Iterator<Item = Cell<'b>> {
match self {
CompatRow::Modern(m) => CompatIter::Modern(m.into_values().map(Cell::Single)),
Expand Down
2 changes: 1 addition & 1 deletion toolset/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bdat-toolset"
authors = ["RoccoDev <[email protected]>"]
version = "0.5.0-alpha"
version = "0.5.0"
edition = "2021"
license = "gpl-3.0"

Expand Down

0 comments on commit a9f64c7

Please sign in to comment.