 		/** An invalid element was found. The element is given in argument to this
 		enum case. */
 		case invalidElementType(CUnsignedChar)
+		
+		/** Found an invalid bool value (given in arg). */
+		case invalidBooleanValue(UInt8)
 		
 		/** Invalid UTF8 string found. The raw data forming the invalid UTF8
 		string is given in argument to this enum case. */

		
		/* Reading the last byte and checking it is indeed 0. */
		let null = try readDataFromBuffer(dataSize: 1, alwaysCopyBytes: false, buffer: buffer, bufferStartPos: &bufferStartPos, bufferValidLength: &bufferValidLength, maxBufferSize: maxBufferSize, totalNReadBytes: &totalNReadBytes, stream: stream)
		assert(null.count <= 1)
		guard null.first == 0 else {throw BSONSerializationError.invalidEndOfString(null.first)}
		
		return str

		case array               = 0x04
		
		/**
		`Data`. Special internal type used by MongoDB replication and sharding.
		First 4 bytes are an increment, second 4 are a timestamp. */
		case timestamp           = 0x11
		/** `Data`. Raw value is an Int32, followed by a subtype (1 byte) then the
		actual bytes. */
		case binary              = 0x05
		/** `Data`. 12 bytes, used by MongoDB. */
		case objectId            = 0x07
		/** `String`. */
		case javascript          = 0x0D
		/**
		`(String, Dictionary)`. Raw value is an Int32 representing the length of
		the whole raw value, then a string, then an embedded BSON doc.
		
		The document is a mapping from identifiers to values, representing the
