def from_bytes(cls, data): if not check_bytes_length(data, 13): return None offset = 1 offset, piece_index = Network.read_integer(data, offset) offset, data_offset = Network.read_integer(data, offset) offset, data_length = Network.read_integer(data, offset) return cls(piece_index, data_offset, data_length)
def from_bytes(cls, data): if not check_minimal_bytes_length(data, 10): return None offset = 1 offset, piece_index = Network.read_integer(data, offset) offset, data_offset = Network.read_integer(data, offset) offset, data_bytes = Network.read_bytes(data, len(data) - offset, offset) return cls(piece_index, data_offset, data_bytes)
def from_bytes(cls, data): if not check_bytes_length(data, 5): return None offset, piece_index = Network.read_integer(data, 1) return cls(piece_index)