pub trait HandleTrait: ToHandle {
    // Provided methods
    fn is_active(&self) -> bool { ... }
    fn is_closing(&self) -> bool { ... }
    fn close<CB: Into<CloseCB<'static>>>(&mut self, cb: CB) { ... }
    fn ref(&mut self) { ... }
    fn unref(&mut self) { ... }
    fn has_ref(&self) -> bool { ... }
    fn send_buffer_size(&mut self, value: i32) -> Result<i32> { ... }
    fn recv_buffer_size(&mut self, value: i32) -> Result<i32> { ... }
    fn get_fileno(&self) -> Result<OsFile> { ... }
    fn get_loop(&self) -> Loop { ... }
    fn get_type(&self) -> HandleType { ... }
}

Provided Methods§

source

fn is_active(&self) -> bool

Returns non-zero if the handle is active, zero if it’s inactive. What “active” means depends on the type of handle:

  • An AsyncHandle is always active and cannot be deactivated, except by closing it with close().
  • A PipeHandle, TcpHandle, UdpHandle, etc. - basically any handle that deals with i/o - is active when it is doing something that involves i/o, like reading, writing, connecting, accepting new connections, etc.
  • A CheckHandle, IdleHandle, TimerHandle, etc. is active when it has been started with a call to start().

Rule of thumb: if a handle start() function, then it’s active from the moment that function is called. Likewise, stop() deactivates the handle again.

source

fn is_closing(&self) -> bool

Returns non-zero if the handle is closing or closed, zero otherwise.

Note: This function should only be used between the initialization of the handle and the arrival of the close callback.

source

fn close<CB: Into<CloseCB<'static>>>(&mut self, cb: CB)

Request handle to be closed. close_cb will be called asynchronously after this call. This MUST be called on each handle before memory is released. Moreover, the memory can only be released in close_cb or after it has returned.

Handles that wrap file descriptors are closed immediately but close_cb will still be deferred to the next iteration of the event loop. It gives you a chance to free up any resources associated with the handle.

In-progress requests, like ConnectRequest or WriteRequest, are cancelled and have their callbacks called asynchronously with status=UV_ECANCELED.

cb can be Nil in cases where no cleanup or deallocation is necessary.

source

fn ref(&mut self)

Reference the given handle. References are idempotent, that is, if a handle is already referenced calling this function again will have no effect.

source

fn unref(&mut self)

Un-reference the given handle. References are idempotent, that is, if a handle is not referenced calling this function again will have no effect.

source

fn has_ref(&self) -> bool

Returns true if the handle referenced, zero otherwise.

source

fn send_buffer_size(&mut self, value: i32) -> Result<i32>

Gets or sets the size of the send buffer that the operating system uses for the socket.

If value == 0, then it will return the current send buffer size. If value > 0 then it will use value to set the new send buffer size and return that.

This function works for TCP, pipe and UDP handles on Unix and for TCP and UDP handles on Windows.

Note: Linux will set double the size and return double the size of the original set value.

source

fn recv_buffer_size(&mut self, value: i32) -> Result<i32>

Gets or sets the size of the receive buffer that the operating system uses for the socket.

If value == 0, then it will return the current receive buffer size. If value > 0 then it will use value to set the new receive buffer size and return that.

This function works for TCP, pipe and UDP handles on Unix and for TCP and UDP handles on Windows.

Note: Linux will set double the size and return double the size of the original set value.

source

fn get_fileno(&self) -> Result<OsFile>

Gets the platform dependent file descriptor equivalent.

The following handles are supported: TCP, pipes, TTY, UDP and poll. Passing any other handle type will fail with EINVAL.

If a handle doesn’t have an attached file descriptor yet or the handle itself has been closed, this function will return EBADF.

Warning: Be very careful when using this function. libuv assumes it’s in control of the file descriptor so any change to it may lead to malfunction.

source

fn get_loop(&self) -> Loop

Returns the Loop associated with this handle.

source

fn get_type(&self) -> HandleType

Returns the type of the handle.

Object Safety§

This trait is not object safe.

Implementors§