class ConfluentSchemaRegistryCoder implements SchemaCoder {

	@Override
	public Schema readSchema(InputStream in) throws IOException {
		DataInputStream dataInputStream = new DataInputStream(in);

		if (dataInputStream.readByte() != 0) {
			throw new IOException("Unknown data format. Magic number does not match");
		} else {
			int schemaId = dataInputStream.readInt();

			try {
				return schemaRegistryClient.getById(schemaId);
			} catch (RestClientException e) {
				throw new IOException(format("Could not find schema with id %s in registry", schemaId), e);
			}
		}
	}

	public  ConfluentSchemaRegistryCoder(SchemaRegistryClient schemaRegistryClient);

}