/// Creates a new circular buffer with the given `size` and `wrap`. The
/// returned `size` and `wrap` will be rounded up to an integer multiple
/// of the granularity. This `size` parameter must be greater than zero.
/// The `wrap` parameter cannot be larger than `size`, but it can be zero.
Creates a new circular buffer with the given `size` and `wrap`. The
returned `size` and `wrap` will be rounded up to an integer multiple
of the granularity. This `size` parameter must be greater than zero.
The `wrap` parameter cannot be larger than `size`, but it can be zero.
Creates a new circular buffer with the given ` size ` and ` wrap ` . The returned ` size ` and ` wrap ` will be rounded up to an integer multiple of the granularity . This ` size ` parameter must be greater than zero . The ` wrap ` parameter cannot be larger than ` size ` but it can be zero .
pub fn new(mut size: usize, mut wrap: usize) -> Result<Buffer, Error> {
        let granularity = Buffer::granularity()?;
        // round up to a multiple of the granularity size, be safe
        size = ((size + granularity - 1) / granularity) * granularity;
        wrap = ((wrap + granularity - 1) / granularity) * granularity;
        if size == 0 || wrap > size {
            return Err(Error::new(ErrorKind::Other, "invalid sizes"));
        }
        // create temporary file name
        let name = format!(
            "/rust-vmcircbuf-{}-{}",
            process::id(),
            BUFFER_ID.fetch_add(1, Ordering::Relaxed)
        );
        unsafe { vm_create(&name, size, wrap) }
    }
pub fn new ( mut size : usize , mut wrap : usize ) -> Result < Buffer , Error > { let granularity = Buffer :: granularity ( ) ? ; // round up to a multiple of the granularity size, be safe size = ( ( size + granularity - 1 ) / granularity ) * granularity ; wrap = ( ( wrap + granularity - 1 ) / granularity ) * granularity ; if size == 0 || wrap > size { return Err ( Error :: new ( ErrorKind :: Other , " " ) ) ; } // create temporary file name let name = format ! ( " " process id ( ) BUFFER_ID fetch_add ( 1 Ordering Relaxed ) ) ; unsafe { vm_create ( & name , size , wrap ) } }
Creates a new circular buffer with the given `size` and `wrap`.
Creates a new circular buffer with the given ` size ` and ` wrap ` .
size
usize
wrap
usize