import datetime
from email._policybase import Policy
from email.message import Message
from imaplib import IMAP4_SSL
import io
from typing import Union, Dict, List, KeysView, Tuple, Optional


class Struct:
    def __init__(self, **entries: Union[
        str, datetime.datetime, Dict[str, str], list, List[Dict[str, str]]
    ]) -> None: ...

    def keys(self) -> KeysView: ...

    def __repr__(self) -> str: ...

def decode_mail_header(value: str, default_charset: str) -> str: ...

def get_mail_addresses(message: Message, header_name: str) -> List[Dict[str, str]]: ...

def decode_param(param: str) -> Tuple[str, str]: ...

def parse_attachment(message_part: Message) -> Optional[Dict[str, Union[int, str, io.BytesIO]]]: ...

def decode_content(message: Message) -> str: ...

def fetch_email_by_uid(uid: bytes, connection: IMAP4_SSL, parser_policy: Optional[Policy]) -> Struct: ...
    raw_headers: bytes
    raw_email: bytes

def parse_flags(headers: str) -> Union[list, List[bytes]]: ...

def parse_email(raw_email: bytes, policy: Optional[Policy]) -> Struct: ...
