uvcc
libuv C++ bindings
uv::fs::sendfile Class Reference

Transfer data between file descriptors. More...

#include "request-fs.hpp"

Inheritance diagram for uv::fs::sendfile:
uv::fs uv::request

Public Types

using on_request_t = std::function< void(sendfile _request) >
 The function type of the callback called when the sendfile request has completed.
 
- Public Types inherited from uv::fs
using uv_t = ::uv_fs_t
 
- Public Types inherited from uv::request
using uv_t = ::uv_req_t
 
using on_destroy_t = std::function< void(void *_data) >
 The function type of the callback called when the request object is about to be destroyed.
 

Public Member Functions

 sendfile (const sendfile &)=default
 
sendfileoperator= (const sendfile &)=default
 
 sendfile (sendfile &&) noexcept=default
 
sendfileoperator= (sendfile &&) noexcept=default
 
on_request_ton_request () const noexcept
 
io handle_out () const noexcept
 The I/O endpoint which this sendfile request has been writing data to. More...
 
file handle_in () const noexcept
 The file which this sendfile request has been reading data from. More...
 
int64_t offset () const noexcept
 The offset this sendfile request has been started to read data at from input file.
 
int run (io &_out, file &_in, int64_t _offset, std::size_t _length)
 Run the request. Read data from the _in file starting from the _offset and copy it to the _out endpoint. More...
 
 operator const uv_t * () const noexcept
 
 operator uv_t * () noexcept
 
- Public Member Functions inherited from uv::fs
 fs (const fs &)=default
 
fsoperator= (const fs &)=default
 
 fs (fs &&) noexcept=default
 
fsoperator= (fs &&) noexcept=default
 
::uv_fs_type fs_type () const noexcept
 The tag indicating a subtype of the filesystem request. More...
 
uv::loop loop () const noexcept
 The libuv loop that started this filesystem request and where completion will be reported.
 
 operator const uv_t * () const noexcept
 
 operator uv_t * () noexcept
 
- Public Member Functions inherited from uv::request
 request (const request &_that)
 
requestoperator= (const request &_that)
 
 request (request &&_that) noexcept
 
requestoperator= (request &&_that) noexcept
 
void swap (request &_that) noexcept
 
std::uintptr_t id () const noexcept
 
long nrefs () const noexcept
 The current number of existing references to the same object as this request variable refers to.
 
int uv_status () const noexcept
 The status value returned by the last executed libuv API function on this request.
 
on_destroy_ton_destroy () const noexcept
 
::uv_req_type type () const noexcept
 The tag indicating a libuv type of the request. More...
 
const char * type_name () const noexcept
 A string containing the name of the request type.
 
void *const & data () const noexcept
 The pointer to the user-defined arbitrary data. libuv and uvcc does not use this field.
 
void *& data () noexcept
 
int cancel () noexcept
 Cancel a pending request. More...
 
 operator const uv_t * () const noexcept
 
 operator uv_t * () noexcept
 
 operator bool () const noexcept
 Equivalent to (uv_status() >= 0).
 

Detailed Description

Transfer data between file descriptors.

Definition at line 896 of file request-fs.hpp.

Member Function Documentation

◆ handle_out()

io uv::fs::sendfile::handle_out ( ) const
inlinenoexcept

The I/O endpoint which this sendfile request has been writing data to.

It is guaranteed that it will be a valid instance at least within the request callback.

Definition at line 961 of file request-fs.hpp.

◆ handle_in()

file uv::fs::sendfile::handle_in ( ) const
inlinenoexcept

The file which this sendfile request has been reading data from.

It is guaranteed that it will be a valid instance at least within the request callback.

Definition at line 964 of file request-fs.hpp.

◆ run()

int uv::fs::sendfile::run ( io _out,
file _in,
int64_t  _offset,
std::size_t  _length 
)
inline

Run the request. Read data from the _in file starting from the _offset and copy it to the _out endpoint.

_length is the number of bytes to be transferred.

See also
libuv API documentation: uv_fs_sendfile().
Linux: sendfile().
Note
If the request callback is empty (has not been set), the request runs synchronously. In this case the function returns a number of bytes copied or relevant libuv error code.

The _offset value of < 0 means using of the current file position.

See also
Windows: _tell(), _telli64().

Definition at line 977 of file request-fs.hpp.


The documentation for this class was generated from the following file: