// Generated by Lisette bindgen
// Source: debug/plan9obj (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.20

import "go:io"

pub fn NewFile(r: io.ReaderAt) -> Result<Ref<File>, error>

pub fn Open(name: string) -> Result<Ref<File>, error>

/// A File represents an open Plan 9 a.out file.
pub struct File {
  pub FileHeader: FileHeader,
  pub Sections: Slice<Option<Ref<Section>>>,
}

/// A FileHeader represents a Plan 9 a.out file header.
pub struct FileHeader {
  pub Magic: uint32,
  pub Bss: uint32,
  pub Entry: uint64,
  pub PtrSize: int,
  pub LoadAddress: uint64,
  pub HdrSize: uint64,
}

/// A Section represents a single section in a Plan 9 a.out file.
pub struct Section {
  pub SectionHeader: SectionHeader,
  pub ReaderAt: Option<io.ReaderAt>,
}

/// A SectionHeader represents a single Plan 9 a.out section header.
/// This structure doesn't exist on-disk, but eases navigation
/// through the object file.
pub struct SectionHeader {
  pub Name: string,
  pub Size: uint32,
  pub Offset: uint32,
}

/// A Symbol represents an entry in a Plan 9 a.out symbol table section.
pub struct Sym {
  pub Value: uint64,
  pub Type: int32,
  pub Name: string,
}

pub const Magic386 = 491

pub const Magic64 = 0x8000

pub const MagicAMD64 = 35479

pub const MagicARM = 1607

/// ErrNoSymbols is returned by [File.Symbols] if there is no such section
/// in the File.
pub var ErrNoSymbols: error

impl File {
  /// Close closes the [File].
  /// If the [File] was created using [NewFile] directly instead of [Open],
  /// Close has no effect.
  #[allow(unused_result)]
  fn Close(self: Ref<File>) -> Result<(), error>

  /// Section returns a section with the given name, or nil if no such
  /// section exists.
  fn Section(self: Ref<File>, name: string) -> Option<Ref<Section>>

  /// Symbols returns the symbol table for f.
  fn Symbols(self: Ref<File>) -> Result<Slice<Sym>, error>
}

impl Section {
  /// Data reads and returns the contents of the Plan 9 a.out section.
  fn Data(self: Ref<Section>) -> Result<Slice<uint8>, error>

  /// Open returns a new ReadSeeker reading the Plan 9 a.out section.
  fn Open(self: Ref<Section>) -> io.ReadSeeker

  fn ReadAt(self, mut p: Slice<uint8>, off: int64) -> Partial<int, error>
}
