Skip to content

Commit 196fa6f

Browse files
cwtchanpac-work
authored andcommitted
refactor: re-organise module structure
Signed-off-by: Chris Chan <chris.chan@techex.co.uk>
1 parent fb060be commit 196fa6f

14 files changed

Lines changed: 52 additions & 48 deletions

File tree

rust/mxl/src/flow.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
pub mod reader;
2+
pub mod writer;
3+
14
use uuid::Uuid;
25

36
use crate::{Error, Result};
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use std::sync::Arc;
22

3-
use crate::flow::is_discrete_data_format;
4-
use crate::grain_reader::GrainReader;
5-
use crate::samples_reader::SamplesReader;
6-
use crate::{DataFormat, Error, Result, flow::FlowInfo, instance::InstanceContext};
3+
use crate::{
4+
DataFormat, Error, GrainReader, Result, SamplesReader,
5+
flow::{FlowInfo, is_discrete_data_format},
6+
instance::InstanceContext,
7+
};
78

89
pub struct MxlFlowReader {
910
context: Arc<InstanceContext>,
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::sync::Arc;
22

3-
use crate::flow::is_discrete_data_format;
4-
use crate::grain_writer::GrainWriter;
5-
use crate::instance::create_flow_reader;
6-
use crate::samples_writer::SamplesWriter;
7-
use crate::{DataFormat, Error, Result, instance::InstanceContext};
3+
use crate::{
4+
flow::is_discrete_data_format,
5+
instance::{create_flow_reader, InstanceContext},
6+
DataFormat, Error, GrainWriter, Result, SamplesWriter,
7+
};
88

99
/// Generic MXL Flow Writer, which can be further used to build either the "discrete" (grain-based
1010
/// data like video frames or meta) or "continuous" (audio samples) flow writers in MXL terminology.

rust/mxl/src/grain.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pub mod data;
2+
pub mod reader;
3+
pub mod write_access;
4+
pub mod writer;
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use std::{sync::Arc, time::Duration};
22

3-
use crate::flow_reader::get_flow_info;
4-
use crate::{Error, GrainData, Result, flow::FlowInfo, instance::InstanceContext};
3+
use crate::{
4+
flow::{reader::get_flow_info, FlowInfo},
5+
instance::InstanceContext,
6+
Error, GrainData, Result,
7+
};
58

69
pub struct GrainReader {
710
context: Arc<InstanceContext>,
@@ -49,8 +52,7 @@ impl GrainReader {
4952
}
5053
if payload_ptr.is_null() {
5154
return Err(Error::Other(format!(
52-
"Failed to get grain payload for index {}.",
53-
index
55+
"Failed to get grain payload for index {index}.",
5456
)));
5557
}
5658
break;
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use std::marker::PhantomData;
2-
use std::sync::Arc;
1+
use std::{marker::PhantomData, sync::Arc};
32

43
use tracing::error;
54

6-
use crate::{Error, Result, instance::InstanceContext};
5+
use crate::{instance::InstanceContext, Error, Result};
76

87
/// RAII grain writing session
98
///
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use std::sync::Arc;
22

3-
use crate::{Error, Result, grain_write_access::GrainWriteAccess, instance::InstanceContext};
3+
use super::write_access::GrainWriteAccess;
4+
5+
use crate::{instance::InstanceContext, Error, Result};
46

57
/// MXL Flow Writer for discrete flows (grain-based data like video frames)
68
pub struct GrainWriter {
@@ -39,8 +41,7 @@ impl GrainWriter {
3941

4042
if payload_ptr.is_null() {
4143
return Err(Error::Other(format!(
42-
"Failed to open grain payload for index {}.",
43-
index
44+
"Failed to open grain payload for index {index}.",
4445
)));
4546
}
4647

rust/mxl/src/lib.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
11
mod api;
22
mod error;
33
mod flow;
4-
mod flow_reader;
5-
mod flow_writer;
6-
mod grain_data;
7-
mod grain_reader;
8-
mod grain_write_access;
9-
mod grain_writer;
4+
mod grain;
105
mod instance;
11-
mod samples_data;
12-
mod samples_reader;
13-
mod samples_write_access;
14-
mod samples_writer;
6+
mod samples;
157

168
pub mod config;
179
pub mod tools;
1810

1911
pub use api::{MxlApi, load_api};
2012
pub use error::{Error, Result};
21-
pub use flow::*;
22-
pub use flow_reader::MxlFlowReader;
23-
pub use flow_writer::MxlFlowWriter;
24-
pub use grain_data::*;
25-
pub use grain_reader::GrainReader;
26-
pub use grain_write_access::GrainWriteAccess;
13+
pub use flow::{reader::MxlFlowReader, writer::MxlFlowWriter, *};
14+
pub use grain::{
15+
data::*, reader::GrainReader, write_access::GrainWriteAccess, writer::GrainWriter,
16+
};
2717
pub use instance::MxlInstance;
28-
pub use samples_data::*;
29-
pub use samples_reader::SamplesReader;
30-
pub use samples_write_access::SamplesWriteAccess;
18+
pub use samples::{
19+
data::*, reader::SamplesReader, write_access::SamplesWriteAccess, writer::SamplesWriter,
20+
};

rust/mxl/src/samples.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pub mod data;
2+
pub mod reader;
3+
pub mod write_access;
4+
pub mod writer;

0 commit comments

Comments
 (0)