-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! The builder module is focused on building a C3d struct for writing to a file. | ||
//! It is focused on composing parts into a valid C3d struct. | ||
use crate::c3d::C3d; | ||
use std::{error::Error, fmt}; | ||
|
||
/// The C3dBuilder is a struct that is used to build a C3d struct. | ||
#[derive(Debug, Default)] | ||
pub struct C3dBuilder { | ||
pub(crate) c3d: C3d, | ||
} | ||
|
||
impl C3dBuilder { | ||
/// Creates a new C3dBuilder. | ||
pub fn new() -> Self { | ||
C3dBuilder { | ||
c3d: C3d::default(), | ||
} | ||
} | ||
|
||
/// Consumes the builder and returns a C3d struct. | ||
pub fn build(self) -> C3d { | ||
self.c3d | ||
} | ||
} | ||
|
||
/// Reports errors in building a C3d struct. | ||
#[derive(Debug)] | ||
pub enum C3dBuilderError { | ||
InvalidParameter, | ||
} | ||
|
||
impl Error for C3dBuilderError {} | ||
impl fmt::Display for C3dBuilderError { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "C3dBuilderError: {:?}", self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters