vfs::directory::watchers::event_producers

Trait EventProducer

Source
pub trait EventProducer {
    // Required methods
    fn mask(&self) -> WatchMask;
    fn event(&self) -> WatchEvent;
    fn prepare_for_next_buffer(&mut self) -> bool;
    fn buffer(&mut self) -> Vec<u8> ;
}
Expand description

Watcher event producer, that generates buffers filled with watcher events. Watchers use this API to obtain buffers that are then sent to the actual watchers. Every producer may generate multiple events, but they all need to be of the same type, as returned by Self::event() and Self::mask() methods.

Required Methods§

Source

fn mask(&self) -> WatchMask

Returns a mask that represents the type of events this producer can generate, as one of the fidl_fuchsia_io::WatchMask::* constants. There might be only one bit set and it should correspond to the event returned by the Self::event() method. It is a duplication, but it helps the callers that need both masks and event IDs.

Source

fn event(&self) -> WatchEvent

Returns an event ID this event producer will use to populate the buffers, as one of the fidl_fuchsia_io::WatchEvent::* constants. Must match what Self::mask(), returns, see there for details.

Source

fn prepare_for_next_buffer(&mut self) -> bool

Checks if this producer can create another buffer, returning true if it can. This method does not actually need to construct the buffer just yet, as an optimization if it will not be needed.

Source

fn buffer(&mut self) -> Vec<u8>

Returns a copy of the current buffer prepared by this producer. This method will be the one constructing a buffer, if necessary, after a preceding call to Self::prepare_for_next_buffer().

Note that this method will keep returning copies of the same buffer, until Self::prepare_for_next_buffer() is not called explicitly.

Implementors§