Class ByteStringParser<T>

  • All Implemented Interfaces:
    Graph<FlowShape<ByteString,​T>,​NotUsed>
    Direct Known Subclasses:
    DeflateDecompressorBase, TcpFraming

    public abstract class ByteStringParser<T>
    extends GraphStage<FlowShape<ByteString,​T>>
    doParse() is the main driver for the parser. It can be called from onPush, onPull and onUpstreamFinish. The general logic is that invocation of this method either results in an emitted parsed element, or an indication that there is more data needed.

    On completion there are various cases: - buffer is empty: parser accepts completion or fails. - buffer is non-empty, we wait for a pull. This might result in a few more onPull-push cycles, served from the buffer. This can lead to two conditions: - drained, empty buffer. This is either accepted completion (acceptUpstreamFinish) or a truncation. - parser demands more data than in buffer. This is always a truncation.

    If the return value is true the method must be called another time to continue processing.