Memory

Struct Memory 

Source
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

Source

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

Source

pub async fn open_memory<T: FromMemoryBackend>( &self, memory: MemoryDevice, ) -> Option<Result<T>>

Get a specific memory by its ID

§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

Source

pub async fn close_memory<T: FromMemoryBackend>(&self, device: T)

Close a memory

§Arguments
  • memory_device - The MemoryDevice struct representing the memory to close
  • backend - The MemoryBackend to return to the subsystem
Source

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§

Source§

impl Debug for Memory

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.