pub fn encode_get(instance: *mut lcb_INSTANCE, request: GetRequest) -> 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_CMDGET = ptr::null_mut();
    unsafe {
        verify(lcb_cmdget_create(&mut command), cookie)?;
        verify(lcb_cmdget_key(command, id.as_ptr(), id_len), cookie)?;
        verify(
            lcb_cmdget_collection(
                command,
                scope.as_ptr(),
                scope_len,
                collection.as_ptr(),
                collection_len,
            ),
            cookie,
        )?;

        match request.ty {
            GetRequestType::Get { options } => {
                if let Some(timeout) = options.timeout {
                    verify(
                        lcb_cmdget_timeout(command, timeout.as_micros() as u32),
                        cookie,
                    )?;
                }
            }
            GetRequestType::GetAndLock { lock_time, options } => {
                verify(
                    lcb_cmdget_locktime(command, lock_time.as_micros() as u32),
                    cookie,
                )?;

                if let Some(timeout) = options.timeout {
                    verify(
                        lcb_cmdget_timeout(command, timeout.as_micros() as u32),
                        cookie,
                    )?;
                }
            }
            GetRequestType::GetAndTouch { expiry, options } => {
                verify(lcb_cmdget_expiry(command, expiry.as_secs() as u32), cookie)?;

                if let Some(timeout) = options.timeout {
                    verify(
                        lcb_cmdget_timeout(command, timeout.as_micros() as u32),
                        cookie,
                    )?;
                }
            }
        };

        verify(lcb_get(instance, cookie as *mut c_void, command), cookie)?;
        verify(lcb_cmdget_destroy(command), cookie)?;
    }
    Ok(())
}
/// Encodes a `GetRequest` into its libcouchbase `lcb_CMDGET` representation.
///
/// Note that this method also handles get_and_lock and get_and_touch by looking
/// at the ty (type) enum of the get request. If one of them is used their inner
/// duration is passed down to libcouchbase either as a locktime or the expiry.
Encodes a `GetRequest` into its libcouchbase `lcb_CMDGET` representation.
Note that this method also handles get_and_lock and get_and_touch by looking
at the ty (type) enum of the get request. If one of them is used their inner
duration is passed down to libcouchbase either as a locktime or the expiry.
Encodes a ` GetRequest ` into its libcouchbase ` lcb_CMDGET ` representation . Note that this method also handles get_and_lock and get_and_touch by looking at the ty ( type ) enum of the get request . If one of them is used their inner duration is passed down to libcouchbase either as a locktime or the expiry .
pub fn encode_get(instance: *mut lcb_INSTANCE, request: GetRequest) -> 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_CMDGET = ptr::null_mut();
    unsafe {
        verify(lcb_cmdget_create(&mut command), cookie)?;
        verify(lcb_cmdget_key(command, id.as_ptr(), id_len), cookie)?;
        verify(
            lcb_cmdget_collection(
                command,
                scope.as_ptr(),
                scope_len,
                collection.as_ptr(),
                collection_len,
            ),
            cookie,
        )?;
        match request.ty {
            GetRequestType::Get { options } => {
                if let Some(timeout) = options.timeout {
                    verify(
                        lcb_cmdget_timeout(command, timeout.as_micros() as u32),
                        cookie,
                    )?;
                }
            }
            GetRequestType::GetAndLock { lock_time, options } => {
                verify(
                    lcb_cmdget_locktime(command, lock_time.as_micros() as u32),
                    cookie,
                )?;
                if let Some(timeout) = options.timeout {
                    verify(
                        lcb_cmdget_timeout(command, timeout.as_micros() as u32),
                        cookie,
                    )?;
                }
            }
            GetRequestType::GetAndTouch { expiry, options } => {
                verify(lcb_cmdget_expiry(command, expiry.as_secs() as u32), cookie)?;
                if let Some(timeout) = options.timeout {
                    verify(
                        lcb_cmdget_timeout(command, timeout.as_micros() as u32),
                        cookie,
                    )?;
                }
            }
        };
        verify(lcb_get(instance, cookie as *mut c_void, command), cookie)?;
        verify(lcb_cmdget_destroy(command), cookie)?;
    }
    Ok(())
}
pub fn encode_get ( instance : * mut lcb_INSTANCE , request : GetRequest ) -> 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_CMDGET = ptr :: null_mut ( ) ; unsafe { verify ( lcb_cmdget_create ( & mut command ) , cookie ) ? ; verify ( lcb_cmdget_key ( command , id . as_ptr ( ) , id_len ) , cookie ) ? ; verify ( lcb_cmdget_collection ( command , scope . as_ptr ( ) , scope_len , collection . as_ptr ( ) , collection_len , ) , cookie , ) ? ; match request . ty { GetRequestType :: Get { options } => { if let Some ( timeout ) = options . timeout { verify ( lcb_cmdget_timeout ( command , timeout . as_micros ( ) as u32 ) , cookie , ) ? ; } } GetRequestType :: GetAndLock { lock_time , options } => { verify ( lcb_cmdget_locktime ( command , lock_time . as_micros ( ) as u32 ) , cookie , ) ? ; if let Some ( timeout ) = options . timeout { verify ( lcb_cmdget_timeout ( command , timeout . as_micros ( ) as u32 ) , cookie , ) ? ; } } GetRequestType :: GetAndTouch { expiry , options } => { verify ( lcb_cmdget_expiry ( command , expiry . as_secs ( ) as u32 ) , cookie ) ? ; if let Some ( timeout ) = options . timeout { verify ( lcb_cmdget_timeout ( command , timeout . as_micros ( ) as u32 ) , cookie , ) ? ; } } } ; verify ( lcb_get ( instance , cookie as * mut c_void , command ) , cookie ) ? ; verify ( lcb_cmdget_destroy ( command ) , cookie ) ? ; } Ok ( ( ) ) }
Encodes a `GetRequest` into its libcouchbase `lcb_CMDGET` representation.
Encodes a ` GetRequest ` into its libcouchbase ` lcb_CMDGET ` representation .
instance
*mut lcb_INSTANCE
request
GetRequest
instance
*mut lcb_INSTANCE
request
GetRequest