pub fn recv<F: FnOnce(*const T, usize) -> usize>(&mut self, f: F) -> Result<Status, Error> {
        let cb = self.buf.load_count()?;
        let l = self.buf.length;
        let n = {
            let data_start = unsafe { self.buf.data.offset(self.index as isize) };
            let data_len = cmp::min(self.index + cb, l) - self.index;

            let n = if data_len == 0 { 0 } else { f(data_start, data_len) };
            if n > data_len { Err(Error::CallbackReadTooMuch)? }
            n
        };

        let c = self.buf.count().fetch_sub(n, Ordering::AcqRel);
        self.index = (self.index + n) % l;
        // dbg!("Recv: cb = {}, c = {}, l = {}, n = {}", cb, c, l, n);
        return Ok(Status {
            remaining: c - n,
            signal: c >= l && n > 0,
        })
    }
/// Lowest level receive function
///
/// The closure will be called with a pointer to the first item and the number of items,
/// and should return the number of items that can be dropped from the buffer.
///
/// Since this is a ringbuffer, there might be more items to read even if you
/// read it all during the closure.
Lowest level receive function
The closure will be called with a pointer to the first item and the number of items,
and should return the number of items that can be dropped from the buffer.

Since this is a ringbuffer, there might be more items to read even if you
read it all during the closure.
Lowest level receive function The closure will be called with a pointer to the first item and the number of items and should return the number of items that can be dropped from the buffer . Since this is a ringbuffer there might be more items to read even if you read it all during the closure .
pub fn recv<F: FnOnce(*const T, usize) -> usize>(&mut self, f: F) -> Result<Status, Error> {
        let cb = self.buf.load_count()?;
        let l = self.buf.length;
        let n = {
            let data_start = unsafe { self.buf.data.offset(self.index as isize) };
            let data_len = cmp::min(self.index + cb, l) - self.index;
            let n = if data_len == 0 { 0 } else { f(data_start, data_len) };
            if n > data_len { Err(Error::CallbackReadTooMuch)? }
            n
        };
        let c = self.buf.count().fetch_sub(n, Ordering::AcqRel);
        self.index = (self.index + n) % l;
        // dbg!("Recv: cb = {}, c = {}, l = {}, n = {}", cb, c, l, n);
        return Ok(Status {
            remaining: c - n,
            signal: c >= l && n > 0,
        })
    }
pub fn recv < F : FnOnce ( * const T , usize ) -> usize > ( & mut self , f : F ) -> Result < Status , Error > { let cb = self . buf . load_count ( ) ? ; let l = self . buf . length ; let n = { let data_start = unsafe { self . buf . data . offset ( self . index as isize ) } ; let data_len = cmp :: min ( self . index + cb , l ) - self . index ; let n = if data_len == 0 { 0 } else { f ( data_start , data_len ) } ; if n > data_len { Err ( Error :: CallbackReadTooMuch ) ? } n } ; let c = self . buf . count ( ) . fetch_sub ( n , Ordering :: AcqRel ) ; self . index = ( self . index + n ) % l ; // dbg!("Recv: cb = {}, c = {}, l = {}, n = {}", cb, c, l, n); return Ok ( Status { remaining : c - n , signal : c >= l && n > 0 , } ) }
Lowest level receive function
The closure will be called with a pointer to the first item and the number of items,
and should return the number of items that can be dropped from the buffer.
Lowest level receive function The closure will be called with a pointer to the first item and the number of items and should return the number of items that can be dropped from the buffer .
&mut self
f
F
&mut self
f
F