package speiger.src.coreengine.assets.impl;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;

import speiger.src.coreengine.assets.api.IAsset;
import speiger.src.coreengine.assets.api.IAssetPackage;
import speiger.src.coreengine.assets.api.IAssetParser;
import speiger.src.coreengine.assets.api.ID;

public record SimpleAsset(IAssetPackage owner, ID location, Path path) implements IAsset {
	
	@Override
	public IAssetPackage owner() {
		return owner;
	}
	
	@Override
	public InputStream stream() throws IOException {
		return Files.newInputStream(path);
	}
	
	@Override
	public <T> T parse(IAssetParser<T> parser) throws IOException {
		return parser.parse(path);
	}
	
}
