pub struct PBufTrip(/* private fields */);
Expand description
Tripwire value used to detect changes
This value is obtained using PipeBuf::tripwire
,
PBufRd::tripwire
or PBufWr::tripwire
, which all calculate
the same value. See also the tripwire!
macro which allows
tuples of tripwire values to be created and compared.
The value will change in these cases:
- Data is written to the pipe
- Data is read from the pipe
- A “push” state is set or consumed
- An EOF state is set or consumed
This value can be compared before and after some operation to detect whether a change has occurred. However that operation must be purely a consumer operation or purely a producer operation. If data is both produced and consumed, then the tripwire value may return to the same value and the change wouldn’t be detected.
These scenarios are supported:
-
In a consumer, avoiding re-parsing an input buffer when there have been no changes made by the producer. Save a
PBufTrip
value before returning, and when called the next time, compare it to the current value. -
In the glue code, detect whether a component call has caused changes to a buffer.
-
In consumer code, check whether some sub-part of the consumer processing has done something.
-
In producer code, check whether some sub-part of the producer processing has done something.