1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// jja: swiss army knife for chess file formats
// src/file.rs: Utilities for binary file I/O
//
// Copyright (c) 2023 Ali Polatel <alip@chesswob.org>
// SPDX-License-Identifier: GPL-3.0-or-later
use ;
/// Writes an integer to a file using a specified number of bytes.
///
/// This function takes a mutable reference to a type implementing the `Write` trait, a length
/// (number of bytes), and an integer value. It writes the integer to the file using the specified
/// number of bytes in big-endian format.
///
/// # Arguments
///
/// * `f` - A mutable reference to a type implementing the `Write` trait.
/// * `l` - The length (number of bytes) to use when writing the integer.
/// * `r` - The integer value to write to the file.
///
/// # Returns
///
/// A `Result<(), io::Error>` indicating success or failure.
/// Reads an integer from a file using a specified number of bytes.
///
/// This function takes a mutable reference to a type implementing the `Read` trait and a length
/// (number of bytes). It reads an integer from the file using the specified number of bytes in
/// big-endian format.
///
/// # Arguments
///
/// * `f` - A mutable reference to a type implementing the `Read` trait.
/// * `l` - The length (number of bytes) to use when reading the integer.
///
/// # Returns
///
/// A `Result<u64, io::Error>` containing the integer value read from the file or an error if
/// reading fails.