Create info method in BlockType.
This commit is contained in:
parent
b48fa03eaa
commit
b8dc6b10bb
84
src/main.rs
84
src/main.rs
|
@ -40,6 +40,50 @@ pub enum BlockType {
|
|||
RepeatEnd,
|
||||
}
|
||||
|
||||
impl BlockType {
|
||||
pub fn info(&self) {
|
||||
match self {
|
||||
BlockType::Terminator => println!("Terminator"),
|
||||
BlockType::SoundData {
|
||||
sample_rate,
|
||||
codec,
|
||||
data,
|
||||
} => {
|
||||
println!(
|
||||
"Sound data: sample rate = {}, codec = {:?}, size = {}",
|
||||
sample_rate,
|
||||
codec,
|
||||
data.len()
|
||||
)
|
||||
}
|
||||
BlockType::SoundDataContinuation { data } => {
|
||||
println!("Sound data continuation: size = {}", data.len())
|
||||
}
|
||||
BlockType::Silence {
|
||||
length,
|
||||
sample_rate,
|
||||
} => {
|
||||
println!(
|
||||
"Silence: length = {}, sample rate = {}",
|
||||
length, sample_rate
|
||||
)
|
||||
}
|
||||
BlockType::Marker { value } => {
|
||||
println!("Marker: value = {}", value)
|
||||
}
|
||||
BlockType::Text { data } => {
|
||||
println!("Text: size = {}", data.len())
|
||||
}
|
||||
BlockType::RepeatStart { count } => {
|
||||
println!("Repeat: repetitions = {}", count)
|
||||
}
|
||||
BlockType::RepeatEnd => {
|
||||
println!("End repeat")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Version {
|
||||
major: u8,
|
||||
|
@ -192,45 +236,7 @@ fn main() {
|
|||
);
|
||||
for (i, block) in voc.blocks.iter().enumerate() {
|
||||
print!("#{} - ", i);
|
||||
match block {
|
||||
BlockType::Terminator => println!("Terminator"),
|
||||
BlockType::SoundData {
|
||||
sample_rate,
|
||||
codec,
|
||||
data,
|
||||
} => {
|
||||
println!(
|
||||
"Sound data: sample rate = {}, codec = {:?}, size = {}",
|
||||
sample_rate,
|
||||
codec,
|
||||
data.len()
|
||||
)
|
||||
}
|
||||
BlockType::SoundDataContinuation { data } => {
|
||||
println!("Sound data continuation: size = {}", data.len())
|
||||
}
|
||||
BlockType::Silence {
|
||||
length,
|
||||
sample_rate,
|
||||
} => {
|
||||
println!(
|
||||
"Silence: length = {}, sample rate = {}",
|
||||
length, sample_rate
|
||||
)
|
||||
}
|
||||
BlockType::Marker { value } => {
|
||||
println!("Marker: value = {}", value)
|
||||
}
|
||||
BlockType::Text { data } => {
|
||||
println!("Text: size = {}", data.len())
|
||||
}
|
||||
BlockType::RepeatStart { count } => {
|
||||
println!("Repeat: repetitions = {}", count)
|
||||
}
|
||||
BlockType::RepeatEnd => {
|
||||
println!("End repeat")
|
||||
}
|
||||
}
|
||||
block.info();
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
|
|
Loading…
Reference in New Issue