/*
 * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
 */

#include <keel/typestore.hpp>

namespace keel {

TypeStore::TypeStore(ox::FileSystem &fs, ox::StringViewCR descPath) noexcept:
	m_fs(fs),
	m_descPath(descPath) {
}

ox::Result<ox::UPtr<ox::DescriptorType>> TypeStore::loadDescriptor(ox::StringView const typeId) noexcept {
	auto const path = ox::sfmt("{}/{}", m_descPath, typeId);
	OX_REQUIRE(buff, m_fs.read(path));
	auto dt = ox::make_unique<ox::DescriptorType>();
	OX_RETURN_ERROR(ox::readClaw<ox::DescriptorType>(buff, *dt));
	return dt;
}

}
