containerization-framework 0.4.0

Rust bindings for Apple's Containerization framework: Linux containers in lightweight VMs, in-process and without a daemon.
//! Virtual machines, vsock, vmnet networks and interfaces, kernels, DNS and
//! hosts.

use super::CzNetwork;
use super::CzOutcome;
use super::HostsEntryName;
use super::InstanceState;
use super::LogLevel;
use super::VirtiofsLayoutKind;
use super::VmnetMode;
use crate::containerization::container;
use crate::containerization::network;
use crate::containerization::vm;
use crate::containerization_extras::address::IPv6Address;
use std::collections::BTreeMap;
use std::convert::Infallible;

taken!(
  vmnet_network -> CzVmnetNetwork,
  optional_vmnet_interface -> Option<network::vmnet_network::Interface>,
  virtual_machine_manager -> CzVirtualMachineManager,
  virtual_machine_instance -> CzVirtualMachineInstance,
  vsock_listener -> CzVsockListener,
  attached_filesystem -> vm::AttachedFilesystem,
  attached_filesystems_by_id -> BTreeMap<String, Vec<vm::AttachedFilesystem>>,
  kernel -> vm::Kernel,
  command_line_kernel_args -> Vec<String>,
  command_line_init_args -> Vec<String>,
  hosts_entry -> network::hosts::Entry,
);

handles!(
  CzVmnetNetwork,
  CzVmnetInterface,
  CzVirtualMachineManager,
  CzVirtualMachineInstance,
  CzVsockListener,
);

failing!(
  cz_vmnet_network_new(VmnetMode, Option<u32>, u8, bool, IPv6Address, u8),
  cz_virtual_machine_manager_new(vm::Kernel, container::Mount, bool, bool),
  cz_install_rosetta(),
  cz_kernel_command_line_add_debug(Vec<String>, Vec<String>),
  cz_kernel_command_line_add_panic(Vec<String>, Vec<String>, i64),
  cz_kernel_command_line_set_agent_log_level(Vec<String>, Vec<String>, LogLevel),
  cz_dns_validate(network::Dns),
  cz_dns_resolv_conf(network::Dns),
  cz_hosts_file(network::Hosts),
  cz_hosts_entry_rendered(network::hosts::Entry),
  cz_hosts_entry_named(HostsEntryName, Option<String>),
  cz_system_platform_oci_platform(vm::SystemPlatform),
);

impl CzVmnetNetwork {
  pub(crate) fn as_network(&self) -> CzNetwork {
    match self.0 {}
  }

  pub(crate) fn subnet(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn prefix_v6(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn ipv4_gateway(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn ipv6_gateway(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn create_interface(&self, _id: &str) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn create_interface_with_mtu(&self, _id: &str, _mtu: u32) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn create_interface_without_gateway(&self, _id: &str) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn release_interface(&self, _id: &str) -> CzOutcome {
    match self.0 {}
  }
}

impl CzVmnetInterface {
  pub(crate) fn duplicate(&self) -> CzVmnetInterface {
    match self.0 {}
  }

  pub(crate) fn ipv4_address(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn ipv4_gateway(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn ipv6_address(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn ipv6_gateway(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn mac_address(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn mtu(&self) -> u32 {
    match self.0 {}
  }
}

impl CzVirtualMachineManager {
  pub(crate) fn duplicate(&self) -> CzVirtualMachineManager {
    match self.0 {}
  }

  pub(crate) fn create(&self, _config: vm::VmConfiguration) -> CzOutcome {
    match self.0 {}
  }
}

impl CzVirtualMachineInstance {
  pub(crate) fn state(&self) -> InstanceState {
    match self.0 {}
  }

  pub(crate) fn mounts(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn virtiofs_layout(&self) -> VirtiofsLayoutKind {
    match self.0 {}
  }

  pub(crate) fn start(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn stop(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn pause(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn resume(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn dial(&self, _port: u32) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn listen(&self, _port: u32) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn hotplug(&self, _block: container::Mount, _id: &str) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn register_mounts(
    &self,
    _id: &str,
    _rootfs: vm::AttachedFilesystem,
    _additional_mounts: Vec<container::Mount>,
  ) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn release_hotplug(&self, _id: &str) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn hotplug_virtio_fs(&self, _mounts: Vec<container::Mount>, _id: &str) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn release_virtio_fs(&self, _id: &str) -> CzOutcome {
    match self.0 {}
  }
}

impl CzVsockListener {
  pub(crate) fn port(&self) -> u32 {
    match self.0 {}
  }

  pub(crate) fn next(&self) -> CzOutcome {
    match self.0 {}
  }

  pub(crate) fn finish(&self) -> CzOutcome {
    match self.0 {}
  }
}