Rust bindings API review #51

Open
rafaelcaricio wants to merge 19 commits from api-review into master
3 changed files with 5 additions and 1 deletions
Showing only changes of commit bc7c06cc8c - Show all commits

View file

@ -21,6 +21,7 @@ parking_lot = "0.11.1"
heapless = "0.7.1" heapless = "0.7.1"
[features] [features]
default = []
alloc = ["cstr_core/alloc"] alloc = ["cstr_core/alloc"]
lvgl_alloc = ["alloc"] lvgl_alloc = ["alloc"]

View file

@ -101,6 +101,9 @@ impl<const N: usize> DrawBuffer<N> {
rafaelcaricio commented 2021-06-04 20:41:26 +00:00 (Migrated from github.com)
Review

TODO: Remove this code duplication.

TODO: Remove this code duplication.
rafaelcaricio commented 2021-06-04 20:43:14 +00:00 (Migrated from github.com)
Review

I use a Mutex here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.

I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
rafaelcaricio commented 2021-06-04 20:41:26 +00:00 (Migrated from github.com)
Review

TODO: Remove this code duplication.

TODO: Remove this code duplication.
rafaelcaricio commented 2021-06-04 20:43:14 +00:00 (Migrated from github.com)
Review

I use a Mutex here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.

I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
fn get_ptr(&self) -> Option<Box<lvgl_sys::lv_disp_buf_t>> { fn get_ptr(&self) -> Option<Box<lvgl_sys::lv_disp_buf_t>> {
if self.initialized.swap_and_check() { if self.initialized.swap_and_check() {
// TODO: needs to be 'static somehow
rafaelcaricio commented 2021-06-04 20:41:26 +00:00 (Migrated from github.com)
Review

TODO: Remove this code duplication.

TODO: Remove this code duplication.
rafaelcaricio commented 2021-06-04 20:43:14 +00:00 (Migrated from github.com)
Review

I use a Mutex here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.

I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
// Cannot be in the DrawBuffer struct because the type `lv_disp_buf_t` contains a raw
rafaelcaricio commented 2021-06-04 20:41:26 +00:00 (Migrated from github.com)
Review

TODO: Remove this code duplication.

TODO: Remove this code duplication.
rafaelcaricio commented 2021-06-04 20:43:14 +00:00 (Migrated from github.com)
Review

I use a Mutex here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.

I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
// pointer and raw pointers are not Sync and consequently cannot be in `static` variables.
rafaelcaricio commented 2021-06-04 20:41:26 +00:00 (Migrated from github.com)
Review

TODO: Remove this code duplication.

TODO: Remove this code duplication.
rafaelcaricio commented 2021-06-04 20:43:14 +00:00 (Migrated from github.com)
Review

I use a Mutex here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.

I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
let mut inner: MaybeUninit<lvgl_sys::lv_disp_buf_t> = MaybeUninit::uninit(); let mut inner: MaybeUninit<lvgl_sys::lv_disp_buf_t> = MaybeUninit::uninit();
let primary_buffer_guard = self.refresh_buffer.lock(); let primary_buffer_guard = self.refresh_buffer.lock();
let draw_buf = unsafe { let draw_buf = unsafe {

rafaelcaricio commented 2021-06-04 20:41:26 +00:00 (Migrated from github.com)
Review

TODO: Remove this code duplication.

TODO: Remove this code duplication.
rafaelcaricio commented 2021-06-04 20:43:14 +00:00 (Migrated from github.com)
Review

I use a Mutex here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.

I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.
rafaelcaricio commented 2021-06-04 20:41:26 +00:00 (Migrated from github.com)
Review

TODO: Remove this code duplication.

TODO: Remove this code duplication.
rafaelcaricio commented 2021-06-04 20:43:14 +00:00 (Migrated from github.com)
Review

I use a Mutex here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.

I use a `Mutex` here, to satisfy the Rust guarantees. But maybe it is not necessary... some food for thought.

View file

@ -14,7 +14,7 @@ pub enum CoreError {
type Result<T> = result::Result<T, CoreError>; type Result<T> = result::Result<T, CoreError>;
/// Register own buffer /// Register own buffer
pub fn disp_drv_register<C: PixelColor + From<Color>, T: DrawTarget<C>>( pub(crate) fn disp_drv_register<C: PixelColor + From<Color>, T: DrawTarget<C>>(
disp_drv: &mut DisplayDriver<T, C>, disp_drv: &mut DisplayDriver<T, C>,
) -> Result<Display> { ) -> Result<Display> {
let disp_ptr = unsafe { lvgl_sys::lv_disp_drv_register(&mut disp_drv.disp_drv as *mut _) }; let disp_ptr = unsafe { lvgl_sys::lv_disp_drv_register(&mut disp_drv.disp_drv as *mut _) };