pub struct Allocator {
pub address: u32,
}Expand description
Allocator for 28-bit memory
This can be used to allocate memory in 28-bit address space.
§Examples
The allocated 28-bit region is described by a fat Ptr28 pointer,
which implements the From trait for common
types such as Vec<u8> and String.
let mut bank = Allocator::new(0x40000);
let a = Vec::<u8>::from([7, 9, 13]);
let ptr = bank.write(a.as_slice()); // dma write
let b = Vec::<u8>::from(ptr); // dma read
assert_eq!(a, b);Vec<Ptr28> can be traversed almost as if a vector of values:
let cnt = Vec::from([bank.push(b"first"), bank.push(b"second")])
.iter()
.copied()
.map(String::from) // dma write
.filter(|s| s.starts_with('s'))
.count();
assert_eq!(cnt, 1);Fields§
§address: u32Current 28-bit address
Implementations§
Auto Trait Implementations§
impl Freeze for Allocator
impl RefUnwindSafe for Allocator
impl Send for Allocator
impl Sync for Allocator
impl Unpin for Allocator
impl UnwindSafe for Allocator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more