/// <summary>
        ///   Reads the next value as a Enumerated with a specified tag, returning the contents
        ///   as a <see cref="ReadOnlyMemory{T}"/> over the original data.
        /// </summary>
        /// <param name="expectedTag">The tag to check for before reading.</param>
        /// <returns>
        ///   The bytes of the Enumerated value, in signed big-endian form.
        /// </returns>
        /// <exception cref="CryptographicException">
        ///   the next value does not have the correct tag --OR--
        ///   the length encoding is not valid under the current encoding rules --OR--
        ///   the contents are not valid under the current encoding rules
        /// </exception>
        /// <exception cref="ArgumentException">
        ///   <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is
        ///   <see cref="TagClass.Universal"/>, but
        ///   <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for
        ///   the method
        /// </exception>
        /// <seealso cref="ReadEnumeratedValue{TEnum}(Asn1Tag)"/>
        public ReadOnlyMemory <byte> ReadEnumeratedBytes(Asn1Tag expectedTag)
        {
            AsnValueReader        valueReader = OpenValueReader();
            ReadOnlySpan <byte>   bytes       = valueReader.ReadEnumeratedBytes(expectedTag);
            ReadOnlyMemory <byte> memory      = AsnValueReader.Slice(_data, bytes);

            valueReader.MatchSlice(ref _data);
            return(memory);
        }
        public bool TryReadPrimitiveBitStringValue(
            Asn1Tag expectedTag,
            out int unusedBitCount,
            out ReadOnlyMemory <byte> value)
        {
            AsnValueReader reader = OpenValueReader();

            if (reader.TryReadPrimitiveBitStringValue(expectedTag, out unusedBitCount, out ReadOnlySpan <byte> span))
            {
                value = AsnValueReader.Slice(_data, span);
                reader.MatchSlice(ref _data);
                return(true);
            }

            value = default;
            return(false);
        }
        private bool TryReadPrimitiveOctetStringBytes(
            Asn1Tag expectedTag,
            UniversalTagNumber universalTagNumber,
            out ReadOnlyMemory <byte> contents)
        {
            AsnValueReader      valueReader = OpenValueReader();
            ReadOnlySpan <byte> span;

            if (valueReader.TryReadPrimitiveOctetStringBytes(expectedTag, universalTagNumber, out span))
            {
                contents = AsnValueReader.Slice(_data, span);
                valueReader.MatchSlice(ref _data);
                return(true);
            }

            contents = default;
            return(false);
        }