def METHOD_NAME(
    self,
    encoding: serialization.Encoding,
    options: typing.Iterable[PKCS7Options],
    backend: typing.Any = None,
) -> bytes:
    if len(self._signers) == 0:
        raise ValueError("Must have at least one signer")
    if self._data is None:
        raise ValueError("You must add data to sign")
    options = list(options)
    if not all(isinstance(x, PKCS7Options) for x in options):
        raise ValueError("options must be from the PKCS7Options enum")
    if encoding not in (
        serialization.Encoding.PEM,
        serialization.Encoding.DER,
        serialization.Encoding.SMIME,
    ):
        raise ValueError(
            "Must be PEM, DER, or SMIME from the Encoding enum"
        )
    # Text is a meaningless option unless it is accompanied by
    # DetachedSignature
    if (
        PKCS7Options.Text in options
        and PKCS7Options.DetachedSignature not in options
    ):
        raise ValueError(
            "When passing the Text option you must also pass "
            "DetachedSignature"
        )
    if PKCS7Options.Text in options and encoding in (
        serialization.Encoding.DER,
        serialization.Encoding.PEM,
    ):
        raise ValueError(
            "The Text option is only available for SMIME serialization"
        )
    # No attributes implies no capabilities so we'll error if you try to
    # pass both.
    if (
        PKCS7Options.NoAttributes in options
        and PKCS7Options.NoCapabilities in options
    ):
        raise ValueError(
            "NoAttributes is a superset of NoCapabilities. Do not pass "
            "both values."
        )
    return rust_pkcs7.sign_and_serialize(self, encoding, options)