// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR MPL-2.0
// SPDX-FileCopyrightText: 2026 Gabriel Marcano <gabemarcano@yahoo.com>

use crate::metadata::Metadata;

use std::io;
use std::io::Read;
use std::io::Seek;
use std::io::SeekFrom;

/// Represents a readable cartridge.
pub struct Cart<T: Read + Seek> {
    /// The cartridge metadata/header.
    pub metadata: Metadata,
    /// The underlying IO object.
    io: T,
}

impl<T: Read + Seek> Read for Cart<T> {
    fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
        self.io.read(buf)
    }
}

impl<T: Read + Seek> Seek for Cart<T> {
    fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
        self.io.seek(pos)
    }
}
