On 27-07-22, 10:57, Kent Gibson wrote:
On Fri, Jul 08, 2022 at 05:04:57PM +0530, Viresh Kumar wrote:
- /// Get the number of events the buffers stores.
stores -> contains
The capacity indicates the number that can be stored. This field indicates the number the buffer currently contains.
And, as mentioned above, rename to len(), and return value should be usize.
Add a set_len() method to replace the max_events parameter in LineRequest::read_edge_event() to handle the unusual case where the user only wants to partially fill the buffer.
So capacity is max that can be stored, len is what is currently present. What read_edge_event() needs is how much we want it to read, which should be <= capacity.
If we remove the parameter to read_edge_event(), then it must fetch the value from the buffer itself, which should be buffer.capacity() if user hasn't called set_len(), else it will be that special value the user sets.
What do you want to call the value (to be added as a field to struct EdgeEventBuffer) and the helper routine to fetch it ?
Maybe we should name it "max_events" and call the helpers as max_events() and set_max_events() instead of set_len()?
- pub fn get_num_events(&self) -> u32 {
unsafe { bindings::gpiod_edge_event_buffer_get_num_events(self.buffer()) as u32 }
- }
+}