*: refactor setters to return self

This commit is contained in:
meh
2015-09-26 18:01:23 +02:00
parent 4747a5a123
commit 510e8604b6
16 changed files with 254 additions and 116 deletions

View File

@ -54,10 +54,12 @@ impl Audio {
}
}
pub fn set_rate(&mut self, rate: i32) {
pub fn set_rate(&mut self, rate: i32) -> &mut Self {
unsafe {
(*self.as_mut_ptr()).sample_rate = rate;
}
self
}
pub fn rate(&self) -> u32 {
@ -66,10 +68,12 @@ impl Audio {
}
}
pub fn set_format(&mut self, value: format::Sample) {
pub fn set_format(&mut self, value: format::Sample) -> &mut Self {
unsafe {
(*self.as_mut_ptr()).sample_fmt = value.into();
}
self
}
pub fn format(&self) -> format::Sample {
@ -78,10 +82,12 @@ impl Audio {
}
}
pub fn set_channel_layout(&mut self, value: ChannelLayout) {
pub fn set_channel_layout(&mut self, value: ChannelLayout) -> &mut Self {
unsafe {
(*self.as_mut_ptr()).channel_layout = value.bits();
}
self
}
pub fn channel_layout(&self) -> ChannelLayout {
@ -90,10 +96,12 @@ impl Audio {
}
}
pub fn set_channels(&mut self, value: i32) {
pub fn set_channels(&mut self, value: i32) -> &mut Self {
unsafe {
(*self.as_mut_ptr()).channels = value;
}
self
}
pub fn channels(&self) -> u16 {