Skip to content

Commit 162920d

Browse files
HEnquistclaude
andcommitted
Implement is_adjustable/is_resizable for Slip
The hardened capability traits added `Resampler::is_adjustable`/`is_resizable` so the capability can be queried through a shared `&dyn Resampler`. `Slip` is both `Adjustable` and `Resizable`, so it must override both to return `true`; otherwise the defaulted `false` would under-report its capabilities through a trait object. Extend the `capability_queries` test to cover `Slip`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 36c00ea commit 162920d

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,13 @@ pub mod tests {
785785
assert!(boxed.as_adjustable().is_some());
786786
assert!(boxed.as_resizable().is_some());
787787

788+
// Slip resamplers are adjustable and resizable, like the async resamplers.
789+
let mut slip = Slip::<f64>::new(1024, 2, FixedAsync::Output).unwrap();
790+
assert!(slip.is_adjustable());
791+
assert!(slip.is_resizable());
792+
assert!(slip.as_adjustable().is_some());
793+
assert!(slip.as_resizable().is_some());
794+
788795
// Synchronous Fft resamplers are neither.
789796
#[cfg(feature = "fft_resampler")]
790797
{

src/slip.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,17 @@ where
499499
Some(self)
500500
}
501501

502+
fn is_adjustable(&self) -> bool {
503+
true
504+
}
505+
502506
fn as_resizable(&mut self) -> Option<&mut dyn Resizable<T>> {
503507
Some(self)
504508
}
509+
510+
fn is_resizable(&self) -> bool {
511+
true
512+
}
505513
}
506514

507515
impl<T> Adjustable<T> for Slip<T>

0 commit comments

Comments
 (0)