oct 0.26.0

Octonary transcodings.
Documentation
// Copyright 2024-2025 Gabriel Bjørnager Jensen.
//
// This Source Code Form is subject to the terms of
// the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, you
// can obtain one at:
// <https://mozilla.org/MPL/2.0/>.

#![doc(html_logo_url = "https://gitlab.com/bjoernager/oct/-/raw/master/DOC-ICON.svg")]

//! Octonary transcoder.
//!
//! This library provides facilities for transcoding
//! objects to and from octonary (bytewise)
//! representations. This includes in-place
//! transmutations (similarly to e.g. Zerocopy and
//! `bytemuck`) as well (de)serialisations
//! (similarly to e.g. Serde and Bincode).
//! Additionally, this crate also provides a port of
//! the [`std::io`] module for use in `no_std`
//! crates.
//!
#![cfg_attr(not(feature = "std"), doc = "[`std::io`]: <https://doc.rust-lang.org/nightly/std/io/index.html>")]

#![no_std]

#![cfg_attr(feature = "f128", feature(f128))]

#![cfg_attr(feature = "f16", feature(f16))]

#![cfg_attr(
	all(
		feature = "f16",
		any(
			target_arch = "aarch64",
			target_arch = "arm64ec",
			target_feature = "v7",
		),
	),
	feature(stdarch_neon_f16),
)]

#![cfg_attr(
	all(
		feature = "f16",
		any(
			target_arch = "x86",
			target_arch = "x86_64",
		),
	),
	feature(stdarch_x86_avx512_f16),
)]

#![cfg_attr(feature = "unstable_docs", feature(doc_cfg, rustdoc_internals))]

#![cfg_attr(feature = "unstable_docs", allow(internal_features))]

extern crate self as oct;

#[cfg(feature = "alloc")]
extern crate alloc;

#[cfg(feature = "std")]
extern crate std;

pub mod io;

mod from_octs;
mod immutable;
mod init;
mod into_octs;
mod transmute;
mod zeroable;

pub use from_octs::FromOcts;
pub use immutable::Immutable;
pub use init::Init;
pub use into_octs::IntoOcts;
pub use transmute::{transmute, transmute_unchecked};
pub use zeroable::Zeroable;

/// Implements [`Immutable`] for the given type.
///
/// [`Immutable`]: trait@Immutable
///
/// # Examples
///
/// Most types can simply derive [`Immutable`],
/// provided that all fields also implement
/// `Immutable`:
///
/// [`Immutable`]: trait@Immutable
///
/// ```rust
/// use oct::Immutable;
///
/// #[derive(Immutable)]
/// struct InteriourImmutableI32 {
///     value: i32,
/// }
/// ```
///
/// Types that contain [`UnsafeCell`] (or other cell
/// types) can thus not derive `Immutable`:
///
/// [`UnsafeCell`]: core::cell::UnsafeCell
///
/// ```rust,compile_fail
/// use core::cell::Cell;
/// use oct::Immutable;
///
/// #[derive(Immutable)]
/// struct InteriourMutableI32 {
///     value: Cell<i32>,
/// }
/// ```
#[cfg(feature = "proc_macro")]
#[doc(inline)]
pub use oct_macros::Immutable;