Skip to content

Commit b108c81

Browse files
committed
refactor: streamline buffer configuration handling across modules
1 parent 5791caf commit b108c81

4 files changed

Lines changed: 74 additions & 254 deletions

File tree

aimdb-core/src/ext_macros.rs

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,11 @@ macro_rules! impl_record_registrar_ext {
116116
) -> &'a mut $crate::RecordRegistrar<'a, T, $runtime> {
117117
use $crate::buffer::Buffer;
118118

119-
#[cfg(feature = "std")]
120-
{
121-
let buffer = Box::new($buffer_new(&cfg));
122-
self.buffer_with_cfg(buffer, cfg)
123-
}
124-
125-
#[cfg(not(feature = "std"))]
126-
{
127-
extern crate alloc;
128-
let buffer = alloc::boxed::Box::new($buffer_new(&cfg));
129-
self.buffer_raw(buffer)
130-
}
119+
extern crate alloc;
120+
let buffer = alloc::boxed::Box::new($buffer_new(&cfg));
121+
// Record the cfg so buffer_info() reports the real buffer
122+
// type/capacity for the dependency graph (std and no_std).
123+
self.buffer_with_cfg(buffer, cfg)
131124
}
132125

133126
fn source<F, Fut>(
@@ -250,18 +243,11 @@ macro_rules! impl_record_registrar_ext {
250243
) -> &'a mut $crate::RecordRegistrar<'a, T, $runtime> {
251244
use $crate::buffer::Buffer;
252245

253-
#[cfg(feature = "std")]
254-
{
255-
let buffer = Box::new($buffer_new(&cfg));
256-
self.buffer_with_cfg(buffer, cfg)
257-
}
258-
259-
#[cfg(not(feature = "std"))]
260-
{
261-
extern crate alloc;
262-
let buffer = alloc::boxed::Box::new($buffer_new(&cfg));
263-
self.buffer_raw(buffer)
264-
}
246+
extern crate alloc;
247+
let buffer = alloc::boxed::Box::new($buffer_new(&cfg));
248+
// Record the cfg so buffer_info() reports the real buffer
249+
// type/capacity for the dependency graph (std and no_std).
250+
self.buffer_with_cfg(buffer, cfg)
265251
}
266252

267253
fn source<F, Fut>(

aimdb-core/src/typed_api.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,7 @@ where
470470
self
471471
}
472472

473-
/// Configures a buffer with metadata tracking (std only)
474-
#[cfg(feature = "std")]
473+
/// Configures a buffer with metadata tracking
475474
pub fn buffer_with_cfg(
476475
&'a mut self,
477476
buffer: Box<dyn crate::buffer::DynBuffer<T>>,
@@ -482,8 +481,7 @@ where
482481
self
483482
}
484483

485-
/// Sets the buffer configuration for metadata tracking (std only)
486-
#[cfg(feature = "std")]
484+
/// Sets the buffer configuration for metadata tracking
487485
pub fn buffer_cfg(&'a mut self, cfg: crate::buffer::BufferCfg) -> &'a mut Self {
488486
self.rec.set_buffer_cfg(cfg);
489487
self

0 commit comments

Comments
 (0)