// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Internal implementation for [`crate::std_io::ext::SeekExt`].
use Result;
use Seek;
use SeekFrom;
/// Measures a stream through a type-erased seekable stream.
///
/// # Parameters
/// - `stream`: Stream to measure and restore.
///
/// # Returns
/// The stream size in bytes.
///
/// # Errors
/// Returns an error when querying the current position, seeking to the end, or
/// restoring the original position fails. If restoring fails, the restore
/// error takes precedence because the stream's original position was not
/// preserved.
pub