"""
This type stub file was generated by pyright.
"""

from typing import Any, Callable
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg

class ForwardMsgQueue:
    """Accumulates a session's outgoing ForwardMsgs.

    Each AppSession adds messages to its queue, and the Server periodically
    flushes all session queues and delivers their messages to the appropriate
    clients.

    ForwardMsgQueue is not thread-safe - a queue should only be used from
    a single thread.
    """
    _before_enqueue_msg: Callable[[ForwardMsg], None] | None = ...
    @staticmethod
    def on_before_enqueue_msg(before_enqueue_msg: Callable[[ForwardMsg], None] | None) -> None:
        """Set a callback to be called before a message is enqueued.
        Used in static streamlit app generation.
        """
        ...
    
    def __init__(self) -> None:
        ...
    
    def get_debug(self) -> dict[str, Any]:
        ...
    
    def is_empty(self) -> bool:
        ...
    
    def enqueue(self, msg: ForwardMsg) -> None:
        """Add message into queue, possibly composing it with another message."""
        ...
    
    def clear(self, retain_lifecycle_msgs: bool = ..., fragment_ids_this_run: list[str] | None = ...) -> None:
        """Clear the queue, potentially retaining lifecycle messages.

        The retain_lifecycle_msgs argument exists because in some cases (in particular
        when a currently running script is interrupted by a new BackMsg), we don't want
        to remove certain messages from the queue as doing so may cause the client to
        not hear about important script lifecycle events (such as the script being
        stopped early in order to be rerun).

        If fragment_ids_this_run is provided, delta messages not belonging to any
        fragment or belonging to a fragment not in fragment_ids_this_run will be
        preserved to prevent clearing messages unrelated to the running fragments.
        """
        ...
    
    def flush(self) -> list[ForwardMsg]:
        """Clear the queue and return a list of the messages it contained
        before being cleared.
        """
        ...
    
    def __len__(self) -> int:
        ...
    


