Improve subclass decide_allocation() / propose_allocation() API

The queries passed in are always allocation queries, so don't require
implementors to match on that first.
This commit is contained in:
Sebastian Dröge 2021-10-16 14:12:50 +03:00
parent 7e71c74505
commit f6cf6c8863
8 changed files with 112 additions and 64 deletions

View file

@ -87,7 +87,7 @@ pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl {
fn propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_propose_allocation(element, query)
}
@ -95,7 +95,7 @@ pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl {
fn decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_decide_allocation(element, query)
}
@ -151,13 +151,13 @@ pub trait AudioDecoderImplExt: ObjectSubclass {
fn parent_propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
}
@ -468,7 +468,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
fn parent_propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -495,7 +495,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -830,7 +830,10 @@ unsafe extern "C" fn audio_decoder_propose_allocation<T: AudioDecoderImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
@ -851,7 +854,10 @@ unsafe extern "C" fn audio_decoder_decide_allocation<T: AudioDecoderImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {

View file

@ -79,7 +79,7 @@ pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl {
fn propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_propose_allocation(element, query)
}
@ -87,7 +87,7 @@ pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl {
fn decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_decide_allocation(element, query)
}
@ -137,13 +137,13 @@ pub trait AudioEncoderImplExt: ObjectSubclass {
fn parent_propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
}
@ -418,7 +418,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
fn parent_propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -445,7 +445,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -750,7 +750,10 @@ unsafe extern "C" fn audio_encoder_propose_allocation<T: AudioEncoderImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
@ -771,7 +774,10 @@ unsafe extern "C" fn audio_encoder_decide_allocation<T: AudioEncoderImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {

View file

@ -153,8 +153,8 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl {
&self,
element: &Self::Type,
pad: &AggregatorPad,
decide_query: &gst::QueryRef,
query: &mut gst::QueryRef,
decide_query: gst::query::Allocation<&gst::QueryRef>,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_propose_allocation(element, pad, decide_query, query)
}
@ -162,7 +162,7 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl {
fn decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_decide_allocation(element, query)
}
@ -289,14 +289,14 @@ pub trait AggregatorImplExt: ObjectSubclass {
&self,
element: &Self::Type,
pad: &AggregatorPad,
decide_query: &gst::QueryRef,
query: &mut gst::QueryRef,
decide_query: gst::query::Allocation<&gst::QueryRef>,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
#[cfg(any(feature = "v1_18", feature = "dox"))]
@ -692,8 +692,8 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
&self,
element: &Self::Type,
pad: &AggregatorPad,
decide_query: &gst::QueryRef,
query: &mut gst::QueryRef,
decide_query: gst::query::Allocation<&gst::QueryRef>,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -722,7 +722,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -1176,8 +1176,14 @@ unsafe extern "C" fn aggregator_propose_allocation<T: AggregatorImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
let decide_query = gst::QueryRef::from_ptr(decide_query);
let query = gst::QueryRef::from_mut_ptr(query);
let decide_query = match gst::QueryRef::from_ptr(decide_query).view() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.propose_allocation(
@ -1203,7 +1209,10 @@ unsafe extern "C" fn aggregator_decide_allocation<T: AggregatorImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {

View file

@ -81,7 +81,7 @@ pub trait BaseSinkImpl: BaseSinkImplExt + ElementImpl {
fn propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_propose_allocation(element, query)
}
@ -137,7 +137,7 @@ pub trait BaseSinkImplExt: ObjectSubclass {
fn parent_propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
}
@ -403,7 +403,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
fn parent_propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -677,7 +677,10 @@ unsafe extern "C" fn base_sink_propose_allocation<T: BaseSinkImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {

View file

@ -111,7 +111,7 @@ pub trait BaseSrcImpl: BaseSrcImplExt + ElementImpl {
fn decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_decide_allocation(element, query)
}
@ -180,7 +180,7 @@ pub trait BaseSrcImplExt: ObjectSubclass {
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
}
@ -587,7 +587,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -1025,7 +1025,10 @@ unsafe extern "C" fn base_src_decide_allocation<T: BaseSrcImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {

View file

@ -138,8 +138,8 @@ pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl {
fn propose_allocation(
&self,
element: &Self::Type,
decide_query: &gst::QueryRef,
query: &mut gst::QueryRef,
decide_query: gst::query::Allocation<&gst::QueryRef>,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_propose_allocation(element, decide_query, query)
}
@ -147,7 +147,7 @@ pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl {
fn decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_decide_allocation(element, query)
}
@ -277,14 +277,14 @@ pub trait BaseTransformImplExt: ObjectSubclass {
fn parent_propose_allocation(
&self,
element: &Self::Type,
decide_query: &gst::QueryRef,
query: &mut gst::QueryRef,
decide_query: gst::query::Allocation<&gst::QueryRef>,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
fn parent_copy_metadata(
@ -717,8 +717,8 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
fn parent_propose_allocation(
&self,
element: &Self::Type,
decide_query: &gst::QueryRef,
query: &mut gst::QueryRef,
decide_query: gst::query::Allocation<&gst::QueryRef>,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -746,7 +746,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -1327,8 +1327,14 @@ unsafe extern "C" fn base_transform_propose_allocation<T: BaseTransformImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
let decide_query = gst::QueryRef::from_ptr(decide_query);
let query = gst::QueryRef::from_mut_ptr(query);
let decide_query = match gst::QueryRef::from_ptr(decide_query).view() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.propose_allocation(wrap.unsafe_cast_ref(), decide_query, query) {
@ -1349,7 +1355,10 @@ unsafe extern "C" fn base_transform_decide_allocation<T: BaseTransformImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {

View file

@ -91,7 +91,7 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl {
fn propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_propose_allocation(element, query)
}
@ -99,7 +99,7 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl {
fn decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_decide_allocation(element, query)
}
@ -166,13 +166,13 @@ pub trait VideoDecoderImplExt: ObjectSubclass {
fn parent_propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
#[cfg(any(feature = "v1_20", feature = "dox"))]
@ -494,7 +494,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
fn parent_propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -521,7 +521,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -878,7 +878,10 @@ unsafe extern "C" fn video_decoder_propose_allocation<T: VideoDecoderImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
@ -899,7 +902,10 @@ unsafe extern "C" fn video_decoder_decide_allocation<T: VideoDecoderImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {

View file

@ -77,7 +77,7 @@ pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl {
fn propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_propose_allocation(element, query)
}
@ -85,7 +85,7 @@ pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl {
fn decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
self.parent_decide_allocation(element, query)
}
@ -131,13 +131,13 @@ pub trait VideoEncoderImplExt: ObjectSubclass {
fn parent_propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage>;
}
@ -410,7 +410,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
fn parent_propose_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -437,7 +437,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
fn parent_decide_allocation(
&self,
element: &Self::Type,
query: &mut gst::QueryRef,
query: gst::query::Allocation<&mut gst::QueryRef>,
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = Self::type_data();
@ -730,7 +730,10 @@ unsafe extern "C" fn video_encoder_propose_allocation<T: VideoEncoderImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
@ -751,7 +754,10 @@ unsafe extern "C" fn video_encoder_decide_allocation<T: VideoEncoderImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.impl_();
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation,
_ => unreachable!(),
};
gst::panic_to_error!(&wrap, imp.panicked(), false, {
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {