Skip to content

Commit

Permalink
Merge branch 'release/v0.8.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
lo48576 committed Jun 27, 2022
2 parents 2bd8891 + a56e216 commit 6a3ab0c
Show file tree
Hide file tree
Showing 39 changed files with 631 additions and 14 deletions.
30 changes: 25 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

## [Unreleased]

## [0.8.1]

* Add types and methods to traverse nodes in depth-first order.
* Add methods to `Tree` to modify node attributes (not only appending).
* Make many (but not all) small methods `#[inline]`.
* Make some funcitions `#[must_use]`.

### Added
* Add types and methods to traverse nodes in depth-first order.
+ `tree::v7400::DepthFirstTraversed` type is added.
+ `tree::v7400::DepthFirstTraverseSubtree` type is added.
* Add methods to `Tree` to modify node attributes (not only appending).
+ `tree::v7400::Tree` has now three new methods: `get_attribute_mut()`,
`take_attributes_vec()`, and `set_attributes_vec()`.

### Changed (non-breaking)
* Make many (but not all) small methods `#[inline]`.
* Make some funcitions `#[must_use]`.

## [0.8.0]

* Bump minimum supported Rust version to 1.56.0.
Expand All @@ -15,18 +34,18 @@
and other commands should still run successfully with stable toolchain.
* Bump internal dependencies.

## Added
### 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
* Fixed incorrect attribute type value being written by the writer.

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

## Non-breaking changes
### Non-breaking changes
* Iterator types returned by `tree::v7400::NodeHandle::{children, children_by_name}`
now have a name.
+ `NodeHandle::children()` returns `Children<'_>`.
Expand Down Expand Up @@ -306,7 +325,8 @@

Totally rewritten.

[Unreleased]: <https://github.com/lo48576/fbxcel/compare/v0.8.0...develop>
[Unreleased]: <https://github.com/lo48576/fbxcel/compare/v0.8.1...develop>
[0.8.1]: <https://github.com/lo48576/fbxcel/releases/tag/v0.8.1>
[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>
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "fbxcel"
version = "0.8.0"
authors = ["YOSHIOKA Takuma <lo48576@hard-wi.red>"]
version = "0.8.1"
authors = ["YOSHIOKA Takuma <nop_thread@nops.red>"]
edition = "2021"
rust-version = "1.56"
license = "MIT OR Apache-2.0"
Expand Down
9 changes: 8 additions & 1 deletion src/low/fbx_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl fmt::Display for HeaderError {
}

impl From<io::Error> for HeaderError {
#[inline]
fn from(e: io::Error) -> Self {
HeaderError::Io(e)
}
Expand Down Expand Up @@ -68,19 +69,25 @@ impl FbxHeader {
}

/// Returns FBX version.
#[inline]
#[must_use]
pub fn version(self) -> FbxVersion {
self.version
}

/// Returns FBX parser version.
///
/// Returns `None` if no parser supports the FBX version.
#[inline]
#[must_use]
pub fn parser_version(self) -> Option<ParserVersion> {
ParserVersion::from_fbx_version(self.version())
}

/// Returns header length in bytes.
pub(crate) fn len(self) -> usize {
#[inline]
#[must_use]
pub(crate) const fn len(self) -> usize {
/// FBX version length.
const VERSION_LEN: usize = 4;

Expand Down
5 changes: 5 additions & 0 deletions src/low/v7400/array_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub enum ArrayAttributeEncoding {

impl ArrayAttributeEncoding {
/// Creates a new `ArrayEncoding` from the given raw value.
#[inline]
#[must_use]
pub(crate) fn from_u32(v: u32) -> Option<Self> {
match v {
0 => Some(ArrayAttributeEncoding::Direct),
Expand All @@ -32,6 +34,8 @@ impl ArrayAttributeEncoding {
/// Returns the raw value.
#[cfg(feature = "writer")]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "writer")))]
#[inline]
#[must_use]
pub(crate) fn to_u32(self) -> u32 {
match self {
ArrayAttributeEncoding::Direct => 0,
Expand All @@ -42,6 +46,7 @@ impl ArrayAttributeEncoding {

impl From<ArrayAttributeEncoding> for Compression {
// Panics if the encoding is `Direct` (i.e. not compressed).
#[inline]
fn from(v: ArrayAttributeEncoding) -> Self {
match v {
ArrayAttributeEncoding::Direct => unreachable!(
Expand Down
2 changes: 2 additions & 0 deletions src/low/v7400/attribute/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub enum AttributeType {

impl AttributeType {
/// Creates an `AttributeType` from the given type code.
#[must_use]
pub(crate) fn from_type_code(code: u8) -> Option<Self> {
match code {
b'C' => Some(AttributeType::Bool),
Expand All @@ -59,6 +60,7 @@ impl AttributeType {
/// Returns the type code.
#[cfg(feature = "writer")]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "writer")))]
#[must_use]
pub(crate) fn type_code(self) -> u8 {
match self {
AttributeType::Bool => b'C',
Expand Down
7 changes: 7 additions & 0 deletions src/low/v7400/attribute/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ pub enum AttributeValue {
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]
#[inline]
#[must_use]
pub fn $opt_getter(&self) -> Option<$ty_ret> {
match self {
AttributeValue::$variant(v) => Some(*v),
Expand All @@ -69,6 +71,8 @@ macro_rules! impl_val_getter {
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]
#[inline]
#[must_use]
pub fn $opt_getter(&self) -> Option<&$ty_ret> {
match self {
AttributeValue::$variant(v) => Some(v),
Expand All @@ -88,6 +92,7 @@ macro_rules! impl_ref_getter {

impl AttributeValue {
/// Returns the value type.
#[must_use]
pub fn type_(&self) -> AttributeType {
match self {
AttributeValue::Bool(_) => AttributeType::Bool,
Expand Down Expand Up @@ -258,13 +263,15 @@ impl AttributeValue {
macro_rules! impl_from {
(direct: $ty:ty, $variant:ident) => {
impl From<$ty> for AttributeValue {
#[inline]
fn from(v: $ty) -> Self {
AttributeValue::$variant(v.into())
}
}
};
(map: $ty:ty, $variant:ident, $arg:ident, $v:expr) => {
impl From<$ty> for AttributeValue {
#[inline]
fn from($arg: $ty) -> Self {
AttributeValue::$variant($v)
}
Expand Down
4 changes: 4 additions & 0 deletions src/low/v7400/node_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub(crate) struct NodeHeader {

impl NodeHeader {
/// Checks whether the entry indicates end of a node.
#[inline]
#[must_use]
pub(crate) fn is_node_end(&self) -> bool {
self.end_offset == 0
&& self.num_attributes == 0
Expand All @@ -30,6 +32,8 @@ impl NodeHeader {
/// Returns node end marker.
#[cfg(feature = "writer")]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "writer")))]
#[inline]
#[must_use]
pub(crate) fn node_end() -> Self {
Self {
end_offset: 0,
Expand Down
20 changes: 15 additions & 5 deletions src/low/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,45 @@ impl FbxVersion {
pub const V7_5: Self = FbxVersion(7500);

/// Creates a new `FbxVersion`.
pub(crate) fn new(version: u32) -> Self {
#[inline]
#[must_use]
pub(crate) const fn new(version: u32) -> Self {
FbxVersion(version)
}

/// Returns the raw value.
///
/// For example, `7400` for FBX 7.4.
pub(crate) fn raw(self) -> u32 {
#[inline]
#[must_use]
pub(crate) const fn raw(self) -> u32 {
self.0
}

/// Returns the major version.
///
/// For example, `7` for FBX 7.4.
pub fn major(self) -> u32 {
#[inline]
#[must_use]
pub const fn major(self) -> u32 {
self.raw() / 1000
}

/// Returns the minor version.
///
/// For example, `4` for FBX 7.4.
pub fn minor(self) -> u32 {
#[inline]
#[must_use]
pub const fn minor(self) -> u32 {
(self.raw() % 1000) / 100
}

/// Returns a tuple of the major and minor verison.
///
/// For example, `(7, 4)` for FBX 7.4.
pub fn major_minor(self) -> (u32, u32) {
#[inline]
#[must_use]
pub const fn major_minor(self) -> (u32, u32) {
let major = self.major();
let minor = self.minor();
(major, minor)
Expand Down
4 changes: 4 additions & 0 deletions src/pull_parser/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ pub enum AnyParser<R> {

impl<R: ParserSource> AnyParser<R> {
/// Returns the parser version.
#[inline]
#[must_use]
pub fn parser_version(&self) -> ParserVersion {
match self {
AnyParser::V7400(_) => pull_parser::v7400::Parser::<R>::PARSER_VERSION,
}
}

/// Returns the FBX version.
#[inline]
#[must_use]
pub fn fbx_version(&self) -> FbxVersion {
match self {
AnyParser::V7400(parser) => parser.fbx_version(),
Expand Down
2 changes: 2 additions & 0 deletions src/pull_parser/any/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub enum Error {
}

impl error::Error for Error {
#[inline]
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
Error::Header(e) => Some(e),
Expand All @@ -36,6 +37,7 @@ impl fmt::Display for Error {
}

impl From<HeaderError> for Error {
#[inline]
fn from(e: HeaderError) -> Self {
Error::Header(e)
}
Expand Down
Loading

0 comments on commit 6a3ab0c

Please sign in to comment.