package com.atlassian.bitbucket.mesh.git.hosting;

import javax.annotation.Nonnull;

/**
 * Callback interface for {@link GitPacketStream}.
 */
public interface GitPacketListener {

    /**
     * Callback method that is called <em>once</em> when {@link GitPacketStream#abort()} is called, the PACK section
     * has been detected, a failure in data analysis occurred, or a non-packet line was detected.
     */
    default void onAborted() {
    }

    /**
     * Callback method. Every time a complete git packet has been appended to {@link GitPacketStream}, the
     * {@link GitPacketListener listeners} get a callback.
     *
     * @param packet the git packet
     */
    void onPacket(@Nonnull byte[] packet);
}
