Skip to content

Commit

Permalink
initial builder commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cvhammond committed Jan 7, 2024
1 parent 8b9cb25 commit d005bb2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
38 changes: 38 additions & 0 deletions src/builder.rs
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)
}
}
12 changes: 2 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,25 @@
use std::path::PathBuf;
use std::{error::Error, fmt};

#[path = "analog.rs"]
pub mod analog;
#[path = "c3d.rs"]
pub mod c3d;
#[path = "data.rs"]
pub mod data;
#[path = "events.rs"]
pub mod events;
#[path = "forces.rs"]
pub mod forces;
#[path = "manufacturer.rs"]
pub mod manufacturer;
#[path = "parameters.rs"]
pub mod parameters;
#[path = "points.rs"]
pub mod points;
#[path = "processor.rs"]
mod processor;
#[path = "seg.rs"]
pub mod seg;
pub mod builder;

#[path = "file_formats/mod.rs"]
pub mod file_formats;

pub use analog::Analog;
pub use analog::AnalogFormat;
pub use analog::AnalogOffset;
pub use builder::C3dBuilder;
pub use c3d::C3d;
pub use data::DataFormat;
pub use data::MarkerPoint;
Expand Down

0 comments on commit d005bb2

Please sign in to comment.