Function linkspace::runtime::lk_watch

source ·
pub fn lk_watch(
    lk: &Linkspace,
    query: &Query,
    cb: impl PktHandler + 'static
) -> LkResult<i32>
Expand description

Registers the query under its ‘qid’ ( .e.g. set by lk_query_parse(q,“:qid:myqid”) ) Before returning, calls cb for every packet in the database. The absolute return value is the number of times the callback was called. A positive value means the callback finished already.

A 0 or negative value means it is registered and shall be called during a [lk_process] or [lk_process_while] call, for every new packet matching the query.

The watch is finished when

  • the cb returns ‘break’ (In other languages we map this to the boolean ‘true’)
  • the predicate set will never match again (e.g. the ‘i_*’ or ‘recv’ predicate shall never match again )
  • [lk_stop] is called with the matching id