//! Yggdrasil OS user-kernel communication ABI
#![no_std]
#![allow(
    clippy::new_without_default,
    clippy::should_implement_trait,
    clippy::module_inception,
    clippy::missing_transmute_annotations,
    incomplete_features,
    stable_features
)]
#![feature(trace_macros, const_trait_impl, ip_in_core)]
#![warn(missing_docs)]

#[cfg(all(any(feature = "alloc", test), not(feature = "rustc-dep-of-std")))]
extern crate alloc;

#[cfg(feature = "rustc-dep-of-std")]
extern crate rustc_std_alloc as alloc;

pub(crate) mod macros;
pub mod util;

pub use abi_lib;
pub use abi_serde;

mod generated {
    #![allow(missing_docs)]

    use crate::{arch::SavedFrame, process::SpawnOption, time::SystemTime, util::FixedString};

    include!(concat!(env!("OUT_DIR"), "/generated_types.rs"));
}

pub mod error {
    //! Error type used by the ABI functions/kernel/runtime

    pub use crate::generated::Error;

    // TODO have syscall-generator implement TryFrom<#repr> for #enum

    impl From<abi_serde::wire::Error> for Error {
        fn from(_value: abi_serde::wire::Error) -> Self {
            Self::InvalidArgument
        }
    }
}

pub use generated::SyscallFunction;

#[macro_use]
pub mod option;

pub mod arch;
pub mod debug;
pub mod io;
pub mod mem;
pub mod net;
pub mod path;
pub mod process;
pub mod system;
pub mod time;
