///
/// HybridOneFileSystemSpec.swift
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

import NitroModules

/// See ``HybridOneFileSystemSpec``
public protocol HybridOneFileSystemSpec_protocol: HybridObject {
  // Properties
  

  // Methods
  func getDirectories() throws -> FileDirectories
  func getInfo(uri: String) throws -> Promise<FileInfo>
  func readDirectory(uri: String) throws -> Promise<[FileEntry]>
  func makeDirectory(uri: String, intermediates: Bool) throws -> Promise<Void>
  func writeFile(uri: String, contents: String, encoding: FileEncoding) throws -> Promise<Void>
  func copy(fromUri: String, toUri: String) throws -> Promise<Void>
  func move(fromUri: String, toUri: String) throws -> Promise<Void>
  func remove(uri: String) throws -> Promise<Void>
  func getBundleDirectory() throws -> String
  func getDiskSpace() throws -> DiskSpace
  func pathInfo(uri: String) throws -> PathStat
  func readText(uri: String) throws -> String
  func readTextAsync(uri: String) throws -> Promise<String>
  func readData(uri: String) throws -> ArrayBuffer
  func readDataAsync(uri: String) throws -> Promise<ArrayBuffer>
  func readBase64(uri: String) throws -> String
  func readBase64Async(uri: String) throws -> Promise<String>
  func writeText(uri: String, contents: String, encoding: FileEncoding, append: Bool) throws -> Void
  func writeTextAsync(uri: String, contents: String, encoding: FileEncoding, append: Bool) throws -> Promise<Void>
  func writeData(uri: String, bytes: ArrayBuffer, append: Bool) throws -> Void
  func writeDataAsync(uri: String, bytes: ArrayBuffer, append: Bool) throws -> Promise<Void>
  func fileDigest(uri: String, algorithm: String) throws -> Promise<String>
  func createFileEntry(uri: String, intermediates: Bool, overwrite: Bool) throws -> Void
  func createDirectoryEntry(uri: String, intermediates: Bool, overwrite: Bool, idempotent: Bool) throws -> Void
  func createFileInDirectory(dirUri: String, name: String) throws -> String
  func createSubdirectory(dirUri: String, name: String) throws -> String
  func deleteEntry(uri: String) throws -> Void
  func renameEntry(uri: String, newName: String) throws -> String
  func copyEntry(fromUri: String, toUri: String, overwrite: Bool) throws -> Void
  func copyEntryAsync(fromUri: String, toUri: String, overwrite: Bool) throws -> Promise<Void>
  func moveEntry(fromUri: String, toUri: String, overwrite: Bool) throws -> Void
  func moveEntryAsync(fromUri: String, toUri: String, overwrite: Bool) throws -> Promise<Void>
  func listEntries(uri: String) throws -> [ListedEntry]
  func fileDetails(uri: String) throws -> DetailedFileInfo
  func directoryDetails(uri: String) throws -> DetailedDirectoryInfo
  func openFile(uri: String, mode: String) throws -> Double
  func closeFile(handle: Double) throws -> Void
  func readHandle(handle: Double, length: Double) throws -> ArrayBuffer
  func readHandleAsync(handle: Double, length: Double) throws -> Promise<ArrayBuffer>
  func writeHandle(handle: Double, bytes: ArrayBuffer) throws -> Void
  func writeHandleAsync(handle: Double, bytes: ArrayBuffer) throws -> Promise<Void>
  func getHandleOffset(handle: Double) throws -> Double
  func setHandleOffset(handle: Double, offset: Double) throws -> Void
  func getHandleSize(handle: Double) throws -> Double
}

public extension HybridOneFileSystemSpec_protocol {
  /// Default implementation of ``HybridObject.toString``
  func toString() -> String {
    return "[HybridObject OneFileSystem]"
  }
}

/// See ``HybridOneFileSystemSpec``
open class HybridOneFileSystemSpec_base {
  private weak var cxxWrapper: HybridOneFileSystemSpec_cxx? = nil
  public init() { }
  public func getCxxWrapper() -> HybridOneFileSystemSpec_cxx {
  #if DEBUG
    guard self is any HybridOneFileSystemSpec else {
      fatalError("`self` is not a `HybridOneFileSystemSpec`! Did you accidentally inherit from `HybridOneFileSystemSpec_base` instead of `HybridOneFileSystemSpec`?")
    }
  #endif
    if let cxxWrapper = self.cxxWrapper {
      return cxxWrapper
    } else {
      let cxxWrapper = HybridOneFileSystemSpec_cxx(self as! any HybridOneFileSystemSpec)
      self.cxxWrapper = cxxWrapper
      return cxxWrapper
    }
  }
}

/**
 * A Swift base-protocol representing the OneFileSystem HybridObject.
 * Implement this protocol to create Swift-based instances of OneFileSystem.
 * ```swift
 * class HybridOneFileSystem : HybridOneFileSystemSpec {
 *   // ...
 * }
 * ```
 */
public typealias HybridOneFileSystemSpec = HybridOneFileSystemSpec_protocol & HybridOneFileSystemSpec_base
