pub struct Memory { /* private fields */ }Expand description
§Access to the Crazyflie Memory Subsystem
This struct provide methods to interact with the memory subsystem. See the memory module documentation for more context and information.
Implementations§
Source§impl Memory
impl Memory
Sourcepub fn get_memories(
&self,
memory_type: Option<MemoryType>,
) -> Vec<&MemoryDevice>
pub fn get_memories( &self, memory_type: Option<MemoryType>, ) -> Vec<&MemoryDevice>
Get the list of memories in the Crazyflie, optionally filtered by type.
If memory_type is None, all memories are returned
If memory_type is Some(type), only memories of that type are returned
§Example
use crazyflie_lib::subsystems::memory::MemoryType;
use crazyflie_lib::{Crazyflie, Value, Error};
use crazyflie_link::LinkContext;
async fn example() -> Result<(), Error> {
let context = LinkContext::new();
let cf = Crazyflie::connect_from_uri(&context, "radio://0/60/2M/E7E7E7E7E7").await?;
let memories = cf.memory.get_memories(Some(MemoryType::OneWire));
Ok(())
};
§Example
use crazyflie_lib::subsystems::memory::MemoryType;
use crazyflie_lib::{Crazyflie, Value, Error};
use crazyflie_link::LinkContext;
async fn example() -> Result<(), Error> {
let context = LinkContext::new();
let cf = Crazyflie::connect_from_uri(&context, "radio://0/60/2M/E7E7E7E7E7").await?;
let memories = cf.memory.get_memories(None);
Ok(())
};§Returns
A vector of references to MemoryDevice structs If no memories are found, an empty vector is returned
Sourcepub async fn open_memory<T: FromMemoryBackend>(
&self,
memory: MemoryDevice,
) -> Option<Result<T>>
pub async fn open_memory<T: FromMemoryBackend>( &self, memory: MemoryDevice, ) -> Option<Result<T>>
Sourcepub async fn close_memory<T: FromMemoryBackend>(&self, device: T)
pub async fn close_memory<T: FromMemoryBackend>(&self, device: T)
Close a memory
§Arguments
memory_device- The MemoryDevice struct representing the memory to closebackend- The MemoryBackend to return to the subsystem
Sourcepub async fn initialize_memory<T: FromMemoryBackend>(
&self,
memory: MemoryDevice,
) -> Option<Result<T>>
pub async fn initialize_memory<T: FromMemoryBackend>( &self, memory: MemoryDevice, ) -> Option<Result<T>>
Get a specific memory by its ID and initialize it according to the defaults. Note that the values will not be written to the memory by default, the user needs to handle this.
§Arguments
memory- The MemoryDevice struct representing the memory to get
§Returns
An Option containing a reference to the MemoryDevice struct if found, or None if not found
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Memory
impl !RefUnwindSafe for Memory
impl Send for Memory
impl Sync for Memory
impl Unpin for Memory
impl !UnwindSafe for Memory
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