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/>.

//! The [`SeekFrom`] enumeration.

/// Seek modes.
#[derive(
	Clone,
	Copy,
	Debug,
	Eq,
	PartialEq,
)]
pub enum SeekFrom {
	/// An offset from the start.
	Start(u64),

	/// An offset from the end.
	End(i64),

	/// An offset from the current position.
	Current(i64),
}

#[cfg(feature = "std")]
impl From<std::io::SeekFrom> for SeekFrom {
	#[inline]
	fn from(value: std::io::SeekFrom) -> Self {
		match value {
			std::io::SeekFrom::Start(offset)   => Self::Start(offset),
			std::io::SeekFrom::End(offset)     => Self::End(offset),
			std::io::SeekFrom::Current(offset) => Self::Current(offset),
		}
	}
}

#[cfg(feature = "std")]
impl From<SeekFrom> for std::io::SeekFrom {
	#[inline]
	fn from(value: SeekFrom) -> Self {
		match value {
			SeekFrom::Start(offset)   => Self::Start(offset),
			SeekFrom::End(offset)     => Self::End(offset),
			SeekFrom::Current(offset) => Self::Current(offset),
		}
	}
}