Skip to content

Commit d6cf64c

Browse files
committed
Clean up encoding methods
1 parent cd3620d commit d6cf64c

File tree

6 files changed

+15
-27
lines changed

6 files changed

+15
-27
lines changed

crates/musli/src/descriptive/encoding.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//! Module that defines [`Encoding`] whith allows for customization of the
2-
//! encoding format, and the [`DEFAULT`] encoding configuration.
3-
41
use core::marker;
52

63
#[cfg(feature = "alloc")]
@@ -25,6 +22,7 @@ use super::error::Error;
2522
/// [`variable length`]: https://en.wikipedia.org/wiki/Variable-length_quantity
2623
pub const OPTIONS: options::Options = options::new().build();
2724

25+
#[allow(unused)]
2826
const DEFAULT: Encoding = Encoding::new();
2927

3028
crate::macros::bare_encoding!(Binary, DEFAULT, descriptive, IntoReader, IntoWriter);

crates/musli/src/json/encoding.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//! Module that defines [`Encoding`] whith allows for customization of the
2-
//! encoding format, and the [`DEFAULT`] encoding configuration.
3-
41
use core::marker;
52

63
#[cfg(feature = "alloc")]
@@ -19,12 +16,12 @@ use super::en::JsonEncoder;
1916
use super::error::Error;
2017
use super::parser::IntoParser;
2118

22-
/// The default encoding instance using the default [`OPTIONS`].
19+
#[allow(unused)]
2320
const DEFAULT: Encoding = Encoding::new();
2421

2522
crate::macros::bare_encoding!(Text, DEFAULT, json, IntoParser, IntoWriter);
2623

27-
/// Encode the given value to a [`String`] using the [`DEFAULT`] [`Encoding`].
24+
/// Encode the given value to a [`String`] using the default [`Encoding`].
2825
///
2926
/// # Examples
3027
///
@@ -59,7 +56,7 @@ where
5956
DEFAULT.to_string(value)
6057
}
6158

62-
/// Decode the given type `T` from the given string using the [`DEFAULT`]
59+
/// Decode the given type `T` from the given string using the default
6360
/// [`Encoding`].
6461
///
6562
/// # Examples

crates/musli/src/macros/internal.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
macro_rules! bare_encoding {
44
($mode:ident, $default:ident, $what:ident, $reader_trait:ident, $writer_trait:ident) => {
5-
/// Encode the given value to the given [`Writer`] using the [`DEFAULT`]
5+
/// Encode the given value to the given [`Writer`] using the default
66
/// [`Encoding`].
77
///
88
/// [`Writer`]: crate::Writer
@@ -43,7 +43,7 @@ macro_rules! bare_encoding {
4343
$default.encode(writer, value)
4444
}
4545

46-
/// Encode the given value to the given slice using the [`DEFAULT`]
46+
/// Encode the given value to the given slice using the default
4747
/// [`Encoding`] and return the number of bytes encoded.
4848
///
4949
/// # Examples
@@ -84,8 +84,7 @@ macro_rules! bare_encoding {
8484
$default.to_slice(out, value)
8585
}
8686

87-
/// Encode the given value to a [`Vec`] using the [`DEFAULT`]
88-
/// [`Encoding`].
87+
/// Encode the given value to a [`Vec`] using the default [`Encoding`].
8988
///
9089
/// [`Vec`]: rust_alloc::vec::Vec
9190
///
@@ -122,7 +121,7 @@ macro_rules! bare_encoding {
122121
$default.to_vec(value)
123122
}
124123

125-
/// Encode the given value to a fixed-size bytes using the [`DEFAULT`]
124+
/// Encode the given value to a fixed-size bytes using the default
126125
/// [`Encoding`].
127126
///
128127
/// ```
@@ -156,7 +155,7 @@ macro_rules! bare_encoding {
156155
$default.to_fixed_bytes::<N, _>(value)
157156
}
158157

159-
/// Encode the given value to the given [`Write`] using the [`DEFAULT`]
158+
/// Encode the given value to the given [`Write`] using the default
160159
/// [`Encoding`].
161160
///
162161
/// [`Write`]: std::io::Write
@@ -197,8 +196,8 @@ macro_rules! bare_encoding {
197196
$default.to_writer(writer, value)
198197
}
199198

200-
/// Decode the given type `T` from the given [`Reader`] using the [`DEFAULT`]
201-
/// [`Encoding`].
199+
/// Decode the given type `T` from the given [`Reader`] using the
200+
/// default [`Encoding`].
202201
///
203202
/// [`Reader`]: crate::Reader
204203
///
@@ -243,7 +242,7 @@ macro_rules! bare_encoding {
243242
$default.decode(reader)
244243
}
245244

246-
/// Decode the given type `T` from the given slice using the [`DEFAULT`]
245+
/// Decode the given type `T` from the given slice using the default
247246
/// [`Encoding`].
248247
///
249248
/// # Examples

crates/musli/src/packed/encoding.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//! Module that defines [`Encoding`] whith allows for customization of the
2-
//! encoding format, and the [`DEFAULT`] encoding configuration.
3-
41
use core::marker;
52

63
#[cfg(feature = "alloc")]
@@ -17,6 +14,7 @@ use crate::storage::en::StorageEncoder;
1714
/// The default options for the packed encoding.
1815
pub const OPTIONS: Options = options::new().fixed().native_byte_order().build();
1916

17+
#[allow(unused)]
2018
const DEFAULT: Encoding = Encoding::new();
2119

2220
crate::macros::bare_encoding!(Binary, DEFAULT, packed, IntoReader, IntoWriter);

crates/musli/src/storage/encoding.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//! Module that defines [`Encoding`] whith allows for customization of the
2-
//! encoding format, and the [`DEFAULT`] encoding configuration.
3-
41
use core::marker;
52

63
#[cfg(feature = "alloc")]
@@ -25,6 +22,7 @@ use super::error::Error;
2522
/// [`variable length`]: https://en.wikipedia.org/wiki/Variable-length_quantity
2623
pub const OPTIONS: Options = options::new().build();
2724

25+
#[allow(unused)]
2826
const DEFAULT: Encoding = Encoding::new();
2927

3028
crate::macros::bare_encoding!(Binary, DEFAULT, storage, IntoReader, IntoWriter);

crates/musli/src/wire/encoding.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//! Module that defines [`Encoding`] whith allows for customization of the
2-
//! encoding format, and the [`DEFAULT`] encoding configuration.
3-
41
use core::marker;
52

63
#[cfg(feature = "alloc")]
@@ -25,6 +22,7 @@ use super::error::Error;
2522
/// [`variable length`]: https://en.wikipedia.org/wiki/Variable-length_quantity
2623
pub const OPTIONS: options::Options = options::new().build();
2724

25+
#[allow(unused)]
2826
const DEFAULT: Encoding = Encoding::new();
2927

3028
crate::macros::bare_encoding!(Binary, DEFAULT, wire, IntoReader, IntoWriter);

0 commit comments

Comments
 (0)