Skip to content

Commit

Permalink
Merge branch 'release/v0.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lo48576 committed Jun 22, 2022
2 parents 0361b33 + 23a6688 commit 2bd8891
Show file tree
Hide file tree
Showing 38 changed files with 293 additions and 188 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ cache: cargo
rust:
- stable
- beta
- 1.40.0
- 1.52.0
jobs:
include:
- rust: 1.40.0
- rust: 1.52.0
env: TEST_MINIMAL_VERSIONS=1
- rust: 1.40.0
- rust: 1.52.0
env: LINT=1
before_install:
- |
Expand Down
42 changes: 41 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,43 @@

## [Unreleased]

## [0.8.0]

* Bump minimum supported Rust version to 1.56.0.
* Iterator types returned by `tree::v7400::NodeHandle::{children, children_by_name}`
now have a name.
* All iterator types now have `std::iter::FusedIterator` impl.
* `tree::v7400::NodeHandle::first_child_by_name()` is added.
* Now some items on docs.rs have pretty badges indicating the items is only
enabled with some features.
+ This won't affect any builds by other users. `cargo doc --all-features`
and other commands should still run successfully with stable toolchain.
* Bump internal dependencies.

## Added
* `tree::v7400::NodeHandle::first_child_by_name()` is added.
+ `node.first_child_by_name(name)` returns the same result as
`node.children_by_name(name).next()`.

## Fixed
* Fixed incorrect attribute type value being written by the writer.

## Breaking changes
* Bump minimum supported Rust version to 1.56.0.

## Non-breaking changes
* Iterator types returned by `tree::v7400::NodeHandle::{children, children_by_name}`
now have a name.
+ `NodeHandle::children()` returns `Children<'_>`.
+ `NodeHandle::children_by_name()` returns `ChildrenByName<'_>`.
+ By this change, now these iterators can be included in other types as a field.
* All iterator types defined by this crate now have `std::iter::FusedIterator` impl.

## [0.7.0]

* Bump minimum supported Rust version to 1.49.
* Bump internal dependencies.

## [0.6.0]

* Minimum supported Rust version is bumped to 1.40.0.
Expand Down Expand Up @@ -269,7 +306,10 @@

Totally rewritten.

[Unreleased]: <https://github.com/lo48576/fbxcel/compare/v0.6.0...develop>
[Unreleased]: <https://github.com/lo48576/fbxcel/compare/v0.8.0...develop>
[0.8.0]: <https://github.com/lo48576/fbxcel/releases/tag/v0.8.0>
[0.7.0]: <https://github.com/lo48576/fbxcel/releases/tag/v0.7.0>
[0.6.1]: <https://github.com/lo48576/fbxcel/releases/tag/v0.6.1>
[0.6.0]: <https://github.com/lo48576/fbxcel/releases/tag/v0.6.0>
[0.5.0]: <https://github.com/lo48576/fbxcel/releases/tag/v0.5.0>
[0.4.4]: <https://github.com/lo48576/fbxcel/releases/tag/v0.4.4>
Expand Down
19 changes: 14 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[package]
name = "fbxcel"
version = "0.6.0"
version = "0.8.0"
authors = ["YOSHIOKA Takuma <[email protected]>"]
edition = "2018"
edition = "2021"
rust-version = "1.56"
license = "MIT OR Apache-2.0"
readme = "README.md"
description = "Excellent FBX library"
Expand All @@ -12,6 +13,14 @@ categories = ["parser-implementations"]

[package.metadata.docs.rs]
all-features = true
# See <https://docs.rs/about/builds>.
#
# Didn't create `docsrs` feature, since this (`#[doc(cfg(feature = ...))]`)
# depends on nightly feature and it prevents `cargo doc --all-features` from
# running with stable rust toolchain.
# See <https://doc.rust-lang.org/rustdoc/unstable-features.html#extensions-to-the-doc-attribute>
# for unstable `#[doc(cfg(...))]` attribute.
rustc-args = ["--cfg", "docsrs"]

[features]
default = []
Expand All @@ -22,12 +31,12 @@ writer = []
[dependencies]
byteorder = "1"
indextree = { version = "4", optional = true }
libflate = "0.1"
libflate = "1.0.1"
log = "0.4.4"
string-interner = { version = "0.7", optional = true, default-features = false }
string-interner = { version = "0.14.0", optional = true, default-features = false, features = ["backends", "inline-more", "std"] }

[dev-dependencies]
env_logger = "0.7"
env_logger = "0.9.0"

[badges]
maintenance = { status = "passively-maintained" }
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://travis-ci.com/lo48576/fbxcel.svg?branch=develop)](https://travis-ci.com/lo48576/fbxcel)
[![Latest version](https://img.shields.io/crates/v/fbxcel.svg)](https://crates.io/crates/fbxcel)
[![Documentation](https://docs.rs/fbxcel/badge.svg)](https://docs.rs/fbxcel)
![Minimum rustc version: 1.40](https://img.shields.io/badge/rustc-1.40+-lightgray.svg)
![Minimum rustc version: 1.56](https://img.shields.io/badge/rustc-1.56+-lightgray.svg)

`fbxcel` is an FBX library for Rust programming language.

Expand Down Expand Up @@ -37,7 +37,7 @@ Currently there is no plan to support FBX ASCII format.

## Rust version

Latest stable compiler (currently 1.40) is supported.
Latest stable compiler (currently 1.52) is supported.

## License

Expand Down
11 changes: 7 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
//! The excellent FBX library.
//!
//! `low` module provides low-level data types such as FBX header, node
//! [`low`] module provides low-level data types such as FBX header, node
//! attribute value, etc.
//!
//! `pull_parser` module provides pull parser for FBX binary format.
//! [`pull_parser`] module provides pull parser for FBX binary format.
//! ASCII format is not supported.
//!
//! `tree` module provides tree types, which allow users to access FBX data as
//! [`tree`] module provides tree types, which allow users to access FBX data as
//! tree, not as stream of parser events.
//! To use `tree` module, enable `tree` feature.
//!
//! `writer` module provides writer types.
//! [`writer`] module provides writer types.
//! To use `writer` module, enable `writer` feature.
#![cfg_attr(feature = "docsrs", feature(doc_cfg))]
#![forbid(unsafe_code)]
#![warn(missing_docs)]
#![warn(clippy::missing_docs_in_private_items)]

pub mod low;
pub mod pull_parser;
#[cfg(feature = "tree")]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "tree")))]
pub mod tree;
#[cfg(feature = "writer")]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "writer")))]
pub mod writer;
1 change: 1 addition & 0 deletions src/low.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Low-level or primitive data types for FBX binary.
#[cfg(feature = "writer")]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "writer")))]
pub(crate) use self::fbx_header::MAGIC;
pub use self::{
fbx_header::{FbxHeader, HeaderError},
Expand Down
8 changes: 4 additions & 4 deletions src/low/fbx_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ mod tests {
let mut cursor = Cursor::new(wrong_header);
// `HeaderError` may contain `io::Error` and is not comparable.
assert!(
match FbxHeader::load(cursor.by_ref()).unwrap_err() {
HeaderError::MagicNotDetected => true,
_ => false,
},
matches!(
FbxHeader::load(cursor.by_ref()),
Err(HeaderError::MagicNotDetected)
),
"Invalid magic should be reported by `MagicNotDetected`"
);
assert!(
Expand Down
3 changes: 2 additions & 1 deletion src/low/v7400/array_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ impl ArrayAttributeEncoding {

/// Returns the raw value.
#[cfg(feature = "writer")]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "writer")))]
pub(crate) fn to_u32(self) -> u32 {
match self {
ArrayAttributeEncoding::Direct => 0,
Expand All @@ -55,7 +56,7 @@ impl FromReader for ArrayAttributeEncoding {
fn from_reader(reader: &mut impl io::Read) -> Result<Self, ParserError> {
let raw_encoding = u32::from_reader(reader)?;
let encoding = ArrayAttributeEncoding::from_u32(raw_encoding)
.ok_or_else(|| DataError::InvalidArrayAttributeEncoding(raw_encoding))?;
.ok_or(DataError::InvalidArrayAttributeEncoding(raw_encoding))?;
Ok(encoding)
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/low/v7400/attribute/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ impl AttributeType {

/// Returns the type code.
#[cfg(feature = "writer")]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "writer")))]
pub(crate) fn type_code(self) -> u8 {
match self {
AttributeType::Bool => b'C',
Expand All @@ -81,7 +82,7 @@ impl FromReader for AttributeType {
fn from_reader(reader: &mut impl io::Read) -> Result<Self, ParserError> {
let type_code = u8::from_reader(reader)?;
let attr_type = Self::from_type_code(type_code)
.ok_or_else(|| DataError::InvalidAttributeTypeCode(type_code))?;
.ok_or(DataError::InvalidAttributeTypeCode(type_code))?;
Ok(attr_type)
}
}
11 changes: 6 additions & 5 deletions src/low/v7400/attribute/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ use crate::low::v7400::AttributeType;
/// * `get_*_or_type()` returns `Result<_, AttributeType>`.
/// + If a value of the expected type available, returns `Ok(_)`.
/// + If not, returns `Ok(ty)` where `ty` is value type (same value as
/// returned by [`type_()`][`type_`].
///
/// [`type_`]: #method.type_
/// returned by [`type_`][`Self::type_()`] method.
#[derive(Debug, Clone, PartialEq)]
pub enum AttributeValue {
/// Single `bool`.
Expand Down Expand Up @@ -46,6 +44,7 @@ pub enum AttributeValue {
Binary(Vec<u8>),
}

/// Implement direct value getters.
macro_rules! impl_val_getter {
($variant:ident, $ty_ret:ty, $opt_getter:ident, $opt_doc:expr, $res_getter:ident, $res_doc:expr,) => {
#[doc = $opt_doc]
Expand All @@ -63,9 +62,10 @@ macro_rules! impl_val_getter {
_ => Err(self.type_()),
}
}
}
};
}

/// Implement value reference getters.
macro_rules! impl_ref_getter {
($variant:ident, $ty_ret:ty, $opt_getter:ident, $opt_doc:expr, $res_getter:ident, $res_doc:expr,) => {
#[doc = $opt_doc]
Expand All @@ -83,7 +83,7 @@ macro_rules! impl_ref_getter {
_ => Err(self.type_()),
}
}
}
};
}

impl AttributeValue {
Expand Down Expand Up @@ -254,6 +254,7 @@ impl AttributeValue {
}
}

/// Implement `From` trait.
macro_rules! impl_from {
(direct: $ty:ty, $variant:ident) => {
impl From<$ty> for AttributeValue {
Expand Down
1 change: 1 addition & 0 deletions src/low/v7400/node_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ impl NodeHeader {

/// Returns node end marker.
#[cfg(feature = "writer")]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "writer")))]
pub(crate) fn node_end() -> Self {
Self {
end_offset: 0,
Expand Down
7 changes: 1 addition & 6 deletions src/pull_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! These modules are common among all supported FBX versions:
//!
//! * Error types (defined in [`error`] module).
//! * [`AnyParser`] feature (defined in [`any`] module).
//! * [`AnyParser`][`any::AnyParser`] feature (defined in [`any`] module).
//! * Parser source traits and wrappers (defined in [`reader`] module).
//!
//! # Using pull parser
Expand Down Expand Up @@ -81,11 +81,6 @@
//! ),
//! }
//! ```
//!
//! [`any`]: any/index.html
//! [`error`]: error/index.html
//! [`reader`]: reader/index.html
//! [`AnyParser`]: any/enum.AnyParser.html
pub use self::{
error::{Error, Result, Warning},
Expand Down
3 changes: 0 additions & 3 deletions src/pull_parser/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ fn parser_version(header: FbxHeader) -> Result<ParserVersion> {
/// This works for seekable readers (which implement [`std::io::Seek`]), but
/// [`from_seekable_reader`] should be used for them, because it is more
/// efficent.
///
/// [`std::io::Seek`]: https://doc.rust-lang.org/stable/std/io/trait.Seek.html
/// [`from_seekable_reader`]: fn.from_seekable_reader.html
pub fn from_reader<R: Read>(mut reader: R) -> Result<AnyParser<PlainSource<R>>> {
let header = FbxHeader::load(&mut reader)?;
match parser_version(header)? {
Expand Down
15 changes: 2 additions & 13 deletions src/pull_parser/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,17 @@ mod source;
/// A trait for types which can be data sources.
///
/// Users can implement this manually, but usually it is enough to use wrappers
/// in the [`reader`] module.
///
/// [`reader`]: index.html
/// in the [`reader`][`self`] module.
pub trait ParserSource: Sized + io::Read {
/// Returns the offset of a byte which would be read next.
///
/// This is called many times during parsing, so it is desirable to be fast
/// as possible.
///
/// Reader types with [`std::io::Seek`] can implement this as
/// `self.seek(SeekFrom::Current(0)).unwrap()`, but this is fallible and
/// `self.stream_position().unwrap()`, but this is fallible and
/// can be inefficient.
/// Use of [`PositionCacheReader`] is reccomended.
///
/// [`std::io::Seek`]: https://doc.rust-lang.org/stable/std/io/trait.Seek.html
/// [`PositionCacheReader`]: struct.PositionCacheReader.html
fn position(&self) -> u64;

/// Skips (seeks formward) the given size.
Expand All @@ -62,9 +57,6 @@ pub trait ParserSource: Sized + io::Read {
/// reader.skip_distance(7).expect("Failed to skip");
/// assert_eq!(reader.position(), 7);
/// ```
///
/// [`std::io::Seek::seek`]:
/// https://doc.rust-lang.org/stable/std/io/trait.Seek.html#tymethod.seek
fn skip_distance(&mut self, distance: u64) -> io::Result<()> {
// NOTE: `let mut limited = self.by_ref().take(distance);` is E0507.
let mut limited = io::Read::take(self.by_ref(), distance);
Expand Down Expand Up @@ -95,9 +87,6 @@ pub trait ParserSource: Sized + io::Read {
/// reader.skip_to(7).expect("Failed to skip");
/// assert_eq!(reader.position(), 7);
/// ```
///
/// [`std::io::Seek::seek`]:
/// https://doc.rust-lang.org/stable/std/io/trait.Seek.html#tymethod.seek
fn skip_to(&mut self, pos: u64) -> io::Result<()> {
let distance = pos
.checked_sub(self.position())
Expand Down
5 changes: 1 addition & 4 deletions src/pull_parser/reader/position_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<R: io::Read> PositionCacheReader<R> {
///
/// A seek beyond the end of a stream is allowed, but behavior is defined by
/// the implementation.
/// See the document for [`std::io::Seek::seek()`][`std::io::Seek::seek`].
/// See the document for [`std::io::Seek::seek()`].
///
/// # Examples
///
Expand All @@ -79,9 +79,6 @@ impl<R: io::Read> PositionCacheReader<R> {
/// reader.skip_distance(7).expect("Failed to skip");
/// assert_eq!(reader.position(), 7);
/// ```
///
/// [`std::io::Seek::seek`]:
/// https://doc.rust-lang.org/stable/std/io/trait.Seek.html#tymethod.seek
pub fn skip_distance(&mut self, mut distance: u64) -> io::Result<()>
where
R: io::Seek,
Expand Down
7 changes: 0 additions & 7 deletions src/pull_parser/reader/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ use crate::pull_parser::{reader::PositionCacheReader, ParserSource};
///
/// This internally uses `PositionCacheReader`, so users don't need to wrap
/// readers by `PositionCacheReader` manually.
///
/// [`std::io::Seek`]: https://doc.rust-lang.org/stable/std/io/trait.Seek.html
/// [`PositionCacheReader`]: struct.PositionCacheReader.html
/// [`SeekableSource`]: struct.SeekableSource.html
#[derive(Debug, Clone, Copy)]
pub struct PlainSource<R> {
/// Inner reader.
Expand Down Expand Up @@ -93,9 +89,6 @@ impl<R: io::Read> ParserSource for PlainSource<R> {
///
/// This internally uses [`PositionCacheReader`], so users don't need to wrap
/// readers by [`PositionCacheReader`] manually.
///
/// [`PlainSource`]: struct.PlainSource.html
/// [`PositionCacheReader`]: struct.PositionCacheReader.html
#[derive(Debug, Clone, Copy)]
pub struct SeekableSource<R> {
/// Inner reader.
Expand Down
Loading

0 comments on commit 2bd8891

Please sign in to comment.