pub unsafe fn push_access<R, E, F>(&mut self, f: F) -> Result<Result<(usize, R), E>, PushAccessError>
    where R: Sized, E: Sized, F: FnOnce(&mut [T], &mut [T]) -> Result<(usize, R), E> {
        let head = self.rb.head.load(Ordering::SeqCst);
        let tail = self.rb.tail.load(Ordering::SeqCst);
        let len = self.rb.data.get_ref().len();

        let ranges = if tail >= head {
            if head > 0 {
                Ok((tail..len, 0..(head - 1)))
            } else {
                if tail < len - 1 {
                    Ok((tail..(len - 1), 0..0))
                } else {
                    Err(PushAccessError::Full)
                }
            }
        } else {
            if tail < head - 1 {
                Ok((tail..(head - 1), 0..0))
            } else {
                Err(PushAccessError::Full)
            }
        }?;

        let slices = (
            &mut self.rb.data.get_mut()[ranges.0],
            &mut self.rb.data.get_mut()[ranges.1],
        );

        match f(slices.0, slices.1) {
            Ok((n, r)) => {
                if n > slices.0.len() + slices.1.len() {
                    Err(PushAccessError::BadLen)
                } else {
                    let new_tail = (tail + n) % len;
                    self.rb.tail.store(new_tail, Ordering::SeqCst);
                    Ok(Ok((n, r)))
                }
            },
            Err(e) => {
                Ok(Err(e))
            }
        }
    }
/// Allows to write into ring buffer memory directry.
///
/// *This function is unsafe beacuse it gives access to possibly uninitialized memory
/// and transfers to the user the responsibility of manually calling destructors*
///
/// Takes a function `f` as argument.
/// `f` takes two slices of ring buffer content (the second one may be empty). First slice contains older elements.
///
/// `f` should return:
/// + On success: pair of number of elements been written, and some arbitrary data.
/// + On failure: some another arbitrary data.
///
/// On success returns data returned from `f`.
Allows to write into ring buffer memory directry.
This function is unsafe beacuse it gives access to possibly uninitialized memory
and transfers to the user the responsibility of manually calling destructors

Takes a function `f` as argument.
`f` takes two slices of ring buffer content (the second one may be empty). First slice contains older elements.

`f` should return:
+ On success: pair of number of elements been written, and some arbitrary data.
+ On failure: some another arbitrary data.

On success returns data returned from `f`.
Allows to write into ring buffer memory directry . This function is unsafe beacuse it gives access to possibly uninitialized memory and transfers to the user the responsibility of manually calling destructors Takes a function ` f ` as argument . ` f ` takes two slices of ring buffer content ( the second one may be empty ) . First slice contains older elements . ` f ` should return : + On success : pair of number of elements been written and some arbitrary data . + On failure : some another arbitrary data . On success returns data returned from ` f ` .
pub unsafe fn push_access<R, E, F>(&mut self, f: F) -> Result<Result<(usize, R), E>, PushAccessError>
    where R: Sized, E: Sized, F: FnOnce(&mut [T], &mut [T]) -> Result<(usize, R), E> {
        let head = self.rb.head.load(Ordering::SeqCst);
        let tail = self.rb.tail.load(Ordering::SeqCst);
        let len = self.rb.data.get_ref().len();
        let ranges = if tail >= head {
            if head > 0 {
                Ok((tail..len, 0..(head - 1)))
            } else {
                if tail < len - 1 {
                    Ok((tail..(len - 1), 0..0))
                } else {
                    Err(PushAccessError::Full)
                }
            }
        } else {
            if tail < head - 1 {
                Ok((tail..(head - 1), 0..0))
            } else {
                Err(PushAccessError::Full)
            }
        }?;
        let slices = (
            &mut self.rb.data.get_mut()[ranges.0],
            &mut self.rb.data.get_mut()[ranges.1],
        );
        match f(slices.0, slices.1) {
            Ok((n, r)) => {
                if n > slices.0.len() + slices.1.len() {
                    Err(PushAccessError::BadLen)
                } else {
                    let new_tail = (tail + n) % len;
                    self.rb.tail.store(new_tail, Ordering::SeqCst);
                    Ok(Ok((n, r)))
                }
            },
            Err(e) => {
                Ok(Err(e))
            }
        }
    }
pub unsafe fn push_access < R , E , F > ( & mut self , f : F ) -> Result < Result < ( usize , R ) , E > , PushAccessError > where R : Sized , E : Sized , F : FnOnce ( & mut [ T ] , & mut [ T ] ) -> Result < ( usize , R ) , E > { let head = self . rb . head . load ( Ordering :: SeqCst ) ; let tail = self . rb . tail . load ( Ordering :: SeqCst ) ; let len = self . rb . data . get_ref ( ) . len ( ) ; let ranges = if tail >= head { if head > 0 { Ok ( ( tail .. len , 0 .. ( head - 1 ) ) ) } else { if tail < len - 1 { Ok ( ( tail .. ( len - 1 ) , 0 .. 0 ) ) } else { Err ( PushAccessError :: Full ) } } } else { if tail < head - 1 { Ok ( ( tail .. ( head - 1 ) , 0 .. 0 ) ) } else { Err ( PushAccessError :: Full ) } } ? ; let slices = ( & mut self . rb . data . get_mut ( ) [ ranges . 0 ] , & mut self . rb . data . get_mut ( ) [ ranges . 1 ] , ) ; match f ( slices . 0 , slices . 1 ) { Ok ( ( n , r ) ) => { if n > slices . 0 . len ( ) + slices . 1 . len ( ) { Err ( PushAccessError :: BadLen ) } else { let new_tail = ( tail + n ) % len ; self . rb . tail . store ( new_tail , Ordering :: SeqCst ) ; Ok ( Ok ( ( n , r ) ) ) } } , Err ( e ) => { Ok ( Err ( e ) ) } } }
Allows to write into ring buffer memory directry.
Allows to write into ring buffer memory directry .
&mut self
f
F
&mut self
f
F