*: refactor setters to return self
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user