pub fn encode_counter(
    instance: *mut lcb_INSTANCE,
    request: CounterRequest,
) -> Result<(), EncodeFailure> {
    let (id_len, id) = into_cstring(request.id);
    let cookie = Box::into_raw(Box::new(request.sender));
    let (scope_len, scope) = into_cstring(request.scope);
    let (collection_len, collection) = into_cstring(request.collection);

    let mut command: *mut lcb_CMDCOUNTER = ptr::null_mut();
    unsafe {
        verify(lcb_cmdcounter_create(&mut command), cookie)?;
        verify(lcb_cmdcounter_key(command, id.as_ptr(), id_len), cookie)?;
        verify(
            lcb_cmdcounter_collection(
                command,
                scope.as_ptr(),
                scope_len,
                collection.as_ptr(),
                collection_len,
            ),
            cookie,
        )?;

        if let Some(cas) = request.options.cas {
            verify(lcb_cmdcounter_cas(command, cas), cookie)?;
        }
        if let Some(timeout) = request.options.timeout {
            verify(
                lcb_cmdcounter_timeout(command, timeout.as_micros() as u32),
                cookie,
            )?;
        }
        if let Some(expiry) = request.options.expiry {
            verify(
                lcb_cmdcounter_expiry(command, expiry.as_secs() as u32),
                cookie,
            )?;
        }

        verify(lcb_cmdcounter_delta(command, request.options.delta), cookie)?;
        verify(
            lcb_counter(instance, cookie as *mut c_void, command),
            cookie,
        )?;
        verify(lcb_cmdcounter_destroy(command), cookie)?;
    }

    Ok(())
}
/// Encodes a `CounterRequest` into its libcouchbase `lcb_CMDCOUNTER` representation.
///
/// This method covers increment and decrement since they are effectively the same operation but
/// with a different operation applied to the delta value.
Encodes a `CounterRequest` into its libcouchbase `lcb_CMDCOUNTER` representation.
This method covers increment and decrement since they are effectively the same operation but
with a different operation applied to the delta value.
Encodes a ` CounterRequest ` into its libcouchbase ` lcb_CMDCOUNTER ` representation . This method covers increment and decrement since they are effectively the same operation but with a different operation applied to the delta value .
pub fn encode_counter(
    instance: *mut lcb_INSTANCE,
    request: CounterRequest,
) -> Result<(), EncodeFailure> {
    let (id_len, id) = into_cstring(request.id);
    let cookie = Box::into_raw(Box::new(request.sender));
    let (scope_len, scope) = into_cstring(request.scope);
    let (collection_len, collection) = into_cstring(request.collection);
    let mut command: *mut lcb_CMDCOUNTER = ptr::null_mut();
    unsafe {
        verify(lcb_cmdcounter_create(&mut command), cookie)?;
        verify(lcb_cmdcounter_key(command, id.as_ptr(), id_len), cookie)?;
        verify(
            lcb_cmdcounter_collection(
                command,
                scope.as_ptr(),
                scope_len,
                collection.as_ptr(),
                collection_len,
            ),
            cookie,
        )?;
        if let Some(cas) = request.options.cas {
            verify(lcb_cmdcounter_cas(command, cas), cookie)?;
        }
        if let Some(timeout) = request.options.timeout {
            verify(
                lcb_cmdcounter_timeout(command, timeout.as_micros() as u32),
                cookie,
            )?;
        }
        if let Some(expiry) = request.options.expiry {
            verify(
                lcb_cmdcounter_expiry(command, expiry.as_secs() as u32),
                cookie,
            )?;
        }
        verify(lcb_cmdcounter_delta(command, request.options.delta), cookie)?;
        verify(
            lcb_counter(instance, cookie as *mut c_void, command),
            cookie,
        )?;
        verify(lcb_cmdcounter_destroy(command), cookie)?;
    }
    Ok(())
}
pub fn encode_counter ( instance : * mut lcb_INSTANCE , request : CounterRequest , ) -> Result < ( ) , EncodeFailure > { let ( id_len , id ) = into_cstring ( request . id ) ; let cookie = Box :: into_raw ( Box :: new ( request . sender ) ) ; let ( scope_len , scope ) = into_cstring ( request . scope ) ; let ( collection_len , collection ) = into_cstring ( request . collection ) ; let mut command : * mut lcb_CMDCOUNTER = ptr :: null_mut ( ) ; unsafe { verify ( lcb_cmdcounter_create ( & mut command ) , cookie ) ? ; verify ( lcb_cmdcounter_key ( command , id . as_ptr ( ) , id_len ) , cookie ) ? ; verify ( lcb_cmdcounter_collection ( command , scope . as_ptr ( ) , scope_len , collection . as_ptr ( ) , collection_len , ) , cookie , ) ? ; if let Some ( cas ) = request . options . cas { verify ( lcb_cmdcounter_cas ( command , cas ) , cookie ) ? ; } if let Some ( timeout ) = request . options . timeout { verify ( lcb_cmdcounter_timeout ( command , timeout . as_micros ( ) as u32 ) , cookie , ) ? ; } if let Some ( expiry ) = request . options . expiry { verify ( lcb_cmdcounter_expiry ( command , expiry . as_secs ( ) as u32 ) , cookie , ) ? ; } verify ( lcb_cmdcounter_delta ( command , request . options . delta ) , cookie ) ? ; verify ( lcb_counter ( instance , cookie as * mut c_void , command ) , cookie , ) ? ; verify ( lcb_cmdcounter_destroy ( command ) , cookie ) ? ; } Ok ( ( ) ) }
Encodes a `CounterRequest` into its libcouchbase `lcb_CMDCOUNTER` representation.
Encodes a ` CounterRequest ` into its libcouchbase ` lcb_CMDCOUNTER ` representation .
instance
*mut lcb_INSTANCE
request
CounterRequest
instance
*mut lcb_INSTANCE
request
CounterRequest