Coverage Report

Created: 2024-05-16 12:16

/__w/smoldot/smoldot/repo/lib/src/util/protobuf.rs
Line
Count
Source (jump to first uncovered line)
1
// Smoldot
2
// Copyright (C) 2019-2022  Parity Technologies (UK) Ltd.
3
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
4
5
// This program is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
15
// You should have received a copy of the GNU General Public License
16
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18
#![allow(unused)] // Some of the functions here might not actually be in use.
19
20
use super::leb128;
21
use alloc::vec::Vec;
22
use core::{iter, str};
23
24
1
pub(crate) fn bool_tag_encode(
25
1
    field: u64,
26
1
    bool_value: bool,
27
1
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone> + Clone {
28
1
    // Note that booleans aren't documented. However, the source code of the official Java
29
1
    // protobuf library encodes them as 1 or 0.
30
1
    // See <https://github.com/protocolbuffers/protobuf/blob/520c601c99012101c816b6ccc89e8d6fc28fdbb8/java/core/src/main/java/com/google/protobuf/CodedOutputStream.java#L447>
31
3
    varint_zigzag_tag_encode(field, if bool_value { 
11
} else {
00
}).
map(1
|b| [b])
_RNCNvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf15bool_tag_encode0B7_
Line
Count
Source
31
3
    varint_zigzag_tag_encode(field, if bool_value { 1 } else { 0 }).map(|b| [b])
Unexecuted instantiation: _RNCNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf15bool_tag_encode0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf15bool_tag_encode0B7_
Unexecuted instantiation: _RNCNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf15bool_tag_encode0CsiUjFBJteJ7x_17smoldot_full_node
32
1
}
_RNvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf15bool_tag_encode
Line
Count
Source
24
1
pub(crate) fn bool_tag_encode(
25
1
    field: u64,
26
1
    bool_value: bool,
27
1
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone> + Clone {
28
1
    // Note that booleans aren't documented. However, the source code of the official Java
29
1
    // protobuf library encodes them as 1 or 0.
30
1
    // See <https://github.com/protocolbuffers/protobuf/blob/520c601c99012101c816b6ccc89e8d6fc28fdbb8/java/core/src/main/java/com/google/protobuf/CodedOutputStream.java#L447>
31
1
    varint_zigzag_tag_encode(field, if bool_value { 1 } else { 
00
}).map(|b| [b])
32
1
}
Unexecuted instantiation: _RNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf15bool_tag_encode
33
34
1
pub(crate) fn uint32_tag_encode(
35
1
    field: u64,
36
1
    value: u32,
37
1
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone> + Clone {
38
6
    varint_zigzag_tag_encode(field, u64::from(value)).map(|b| [b])
_RNCNvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf17uint32_tag_encode0B7_
Line
Count
Source
38
6
    varint_zigzag_tag_encode(field, u64::from(value)).map(|b| [b])
Unexecuted instantiation: _RNCNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17uint32_tag_encode0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17uint32_tag_encode0B7_
Unexecuted instantiation: _RNCNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17uint32_tag_encode0CsiUjFBJteJ7x_17smoldot_full_node
39
1
}
_RNvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf17uint32_tag_encode
Line
Count
Source
34
1
pub(crate) fn uint32_tag_encode(
35
1
    field: u64,
36
1
    value: u32,
37
1
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone> + Clone {
38
1
    varint_zigzag_tag_encode(field, u64::from(value)).map(|b| [b])
39
1
}
Unexecuted instantiation: _RNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17uint32_tag_encode
40
41
221
pub(crate) fn enum_tag_encode(
42
221
    field: u64,
43
221
    enum_value: u64,
44
221
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone> + Clone {
45
445
    varint_zigzag_tag_encode(field, enum_value).map(|b| [b])
_RNCNvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf15enum_tag_encode0B7_
Line
Count
Source
45
111
    varint_zigzag_tag_encode(field, enum_value).map(|b| [b])
Unexecuted instantiation: _RNCNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf15enum_tag_encode0CsDDUKWWCHAU_18smoldot_light_wasm
_RNCNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf15enum_tag_encode0B7_
Line
Count
Source
45
334
    varint_zigzag_tag_encode(field, enum_value).map(|b| [b])
Unexecuted instantiation: _RNCNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf15enum_tag_encode0CsiUjFBJteJ7x_17smoldot_full_node
46
221
}
_RNvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf15enum_tag_encode
Line
Count
Source
41
54
pub(crate) fn enum_tag_encode(
42
54
    field: u64,
43
54
    enum_value: u64,
44
54
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone> + Clone {
45
54
    varint_zigzag_tag_encode(field, enum_value).map(|b| [b])
46
54
}
_RNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf15enum_tag_encode
Line
Count
Source
41
167
pub(crate) fn enum_tag_encode(
42
167
    field: u64,
43
167
    enum_value: u64,
44
167
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone> + Clone {
45
167
    varint_zigzag_tag_encode(field, enum_value).map(|b| [b])
46
167
}
47
48
0
pub(crate) fn message_tag_encode<'a>(
49
0
    field: u64,
50
0
    inner_message: impl Iterator<Item = impl AsRef<[u8]> + 'a> + 'a,
51
0
) -> impl Iterator<Item = impl AsRef<[u8]> + 'a> + 'a {
52
0
    // We have to buffer the inner message into a `Vec` in order to determine its length. The
53
0
    // alternative would have been to require a `Clone` bound on the inner message iterator, but
54
0
    // that would be overly restrictive.
55
0
56
0
    // A relatively high initial capacity is used in order to avoid many reallocations. The actual
57
0
    // value is arbitrary.
58
0
    let inner_message = inner_message.fold(Vec::with_capacity(1024), |mut a, b| {
59
0
        a.extend_from_slice(b.as_ref());
60
0
        a
61
0
    });
Unexecuted instantiation: _RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf18message_tag_encodeppE0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB13_Ahj20_Ahj1_EIB13_IB13_INtNvB4_17string_tag_encode7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEB1I_EIB13_INtNtB2C_3vec3VechEB1I_EEEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainIB3L_INtNtB3P_3map3MapIB3L_IB4I_IB3L_NtNvNtB6_6leb1286encode10EncodeIterB5d_ENCINvB4_20delimited_tag_encodeB1C_E0EINtNtNtB3R_7sources4once4OnceB1x_EENcNtB12_4Left0EIB4I_IB4I_IB3L_IB4I_B58_NCIB5U_B1Y_E0EIB6t_B1T_EENcNtB1O_4Left0ENcNtB12_5Right0EEIB4I_IB4I_IB3L_IB4I_B58_NCIB5U_B3k_E0EIB6t_B3f_EENcNtB1O_5Right0EB8i_EEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB13_Ahj20_Ahj1_EIB13_INtNtCsdZExvAaxgia_5alloc3vec3VechEB1I_EEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainINtNtB2D_3map3MapIB2z_IB3r_IB2z_NtNvNtB6_6leb1286encode10EncodeIterB3W_ENCINvB4_20delimited_tag_encodeB1C_E0EINtNtNtB2F_7sources4once4OnceB1x_EENcNtB12_4Left0EIB3r_INtNtB2D_7flatten7FlatMapINtNtB1W_9into_iter8IntoIterB1T_EIB2z_IB3r_B3R_NCIB4D_B1T_E0EIB5c_B1O_EENCINvNtNtNtB8_7network5codec18storage_call_proof27build_storage_proof_requestB1T_B6t_E0ENcNtB12_5Right0EEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeppE0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB13_Ahj20_Ahj1_EIB13_IB13_INtNvB4_17string_tag_encode7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEB1I_EIB13_INtNtB2C_3vec3VechEB1I_EEEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainIB3L_INtNtB3P_3map3MapIB3L_IB4I_IB3L_NtNvNtB6_6leb1286encode10EncodeIterB5d_ENCINvB4_20delimited_tag_encodeB1C_E0EINtNtNtB3R_7sources4once4OnceB1x_EENcNtB12_4Left0EIB4I_IB4I_IB3L_IB4I_B58_NCIB5U_B1Y_E0EIB6t_B1T_EENcNtB1O_4Left0ENcNtB12_5Right0EEIB4I_IB4I_IB3L_IB4I_B58_NCIB5U_B3k_E0EIB6t_B3f_EENcNtB1O_5Right0EB8i_EEE0CsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB13_Ahj20_Ahj1_EIB13_INtNtCsdZExvAaxgia_5alloc3vec3VechEB1I_EEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainINtNtB2D_3map3MapIB2z_IB3r_IB2z_NtNvNtB6_6leb1286encode10EncodeIterB3W_ENCINvB4_20delimited_tag_encodeB1C_E0EINtNtNtB2F_7sources4once4OnceB1x_EENcNtB12_4Left0EIB3r_INtNtB2D_7flatten7FlatMapINtNtB1W_9into_iter8IntoIterB1T_EIB2z_IB3r_B3R_NCIB4D_B1T_E0EIB5c_B1O_EENCINvNtNtNtB8_7network5codec18storage_call_proof27build_storage_proof_requestB1T_B6t_E0ENcNtB12_5Right0EEE0CsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB13_IB13_Ahj20_Ahj1_EIB13_INtNtCsdZExvAaxgia_5alloc3vec3VechEB1N_EEIB13_B1T_B1T_EEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainINtNtB2X_3map3MapIB2T_IB3L_IB2T_IB3L_IB2T_NtNvNtB6_6leb1286encode10EncodeIterB4q_ENCINvB4_20delimited_tag_encodeB1H_E0EINtNtNtB2Z_7sources4once4OnceB1C_EENcNtB1x_4Left0EIB3L_INtNtB2X_7flatten7FlatMapINtNtB31_6option8IntoIterB1Y_EIB2T_IB3L_B4l_NCIB57_B1Y_E0EIB5G_B1T_EENCNCNvNtNtNtB8_7network5codec13block_request20build_block_response0s_0ENcNtB1x_5Right0EENcNtB12_4Left0EIB3L_IB2T_IB3L_IB6z_IB6z_IB6Y_IB1Z_B1Y_EEINtNtB21_9into_iter8IntoIterB1Y_ENCB86_s0_0EB7r_NCB86_s1_0ENcNtB2D_4Left0EIB3L_IB6z_B6X_B7r_NCB86_s2_0ENcNtB2D_5Right0EENcNtB12_5Right0EEE0CsiUjFBJteJ7x_17smoldot_full_node
62
0
63
0
    tag_encode(field, 2)
64
0
        .chain(leb128::encode_usize(inner_message.len()))
65
0
        .map(|v| either::Right([v]))
Unexecuted instantiation: _RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf18message_tag_encodeppEs_0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB13_Ahj20_Ahj1_EIB13_IB13_INtNvB4_17string_tag_encode7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEB1I_EIB13_INtNtB2C_3vec3VechEB1I_EEEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainIB3L_INtNtB3P_3map3MapIB3L_IB4I_IB3L_NtNvNtB6_6leb1286encode10EncodeIterB5d_ENCINvB4_20delimited_tag_encodeB1C_E0EINtNtNtB3R_7sources4once4OnceB1x_EENcNtB12_4Left0EIB4I_IB4I_IB3L_IB4I_B58_NCIB5U_B1Y_E0EIB6t_B1T_EENcNtB1O_4Left0ENcNtB12_5Right0EEIB4I_IB4I_IB3L_IB4I_B58_NCIB5U_B3k_E0EIB6t_B3f_EENcNtB1O_5Right0EB8i_EEEs_0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB13_Ahj20_Ahj1_EIB13_INtNtCsdZExvAaxgia_5alloc3vec3VechEB1I_EEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainINtNtB2D_3map3MapIB2z_IB3r_IB2z_NtNvNtB6_6leb1286encode10EncodeIterB3W_ENCINvB4_20delimited_tag_encodeB1C_E0EINtNtNtB2F_7sources4once4OnceB1x_EENcNtB12_4Left0EIB3r_INtNtB2D_7flatten7FlatMapINtNtB1W_9into_iter8IntoIterB1T_EIB2z_IB3r_B3R_NCIB4D_B1T_E0EIB5c_B1O_EENCINvNtNtNtB8_7network5codec18storage_call_proof27build_storage_proof_requestB1T_B6t_E0ENcNtB12_5Right0EEEs_0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeppEs_0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB13_Ahj20_Ahj1_EIB13_IB13_INtNvB4_17string_tag_encode7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEB1I_EIB13_INtNtB2C_3vec3VechEB1I_EEEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainIB3L_INtNtB3P_3map3MapIB3L_IB4I_IB3L_NtNvNtB6_6leb1286encode10EncodeIterB5d_ENCINvB4_20delimited_tag_encodeB1C_E0EINtNtNtB3R_7sources4once4OnceB1x_EENcNtB12_4Left0EIB4I_IB4I_IB3L_IB4I_B58_NCIB5U_B1Y_E0EIB6t_B1T_EENcNtB1O_4Left0ENcNtB12_5Right0EEIB4I_IB4I_IB3L_IB4I_B58_NCIB5U_B3k_E0EIB6t_B3f_EENcNtB1O_5Right0EB8i_EEEs_0CsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB13_Ahj20_Ahj1_EIB13_INtNtCsdZExvAaxgia_5alloc3vec3VechEB1I_EEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainINtNtB2D_3map3MapIB2z_IB3r_IB2z_NtNvNtB6_6leb1286encode10EncodeIterB3W_ENCINvB4_20delimited_tag_encodeB1C_E0EINtNtNtB2F_7sources4once4OnceB1x_EENcNtB12_4Left0EIB3r_INtNtB2D_7flatten7FlatMapINtNtB1W_9into_iter8IntoIterB1T_EIB2z_IB3r_B3R_NCIB4D_B1T_E0EIB5c_B1O_EENCINvNtNtNtB8_7network5codec18storage_call_proof27build_storage_proof_requestB1T_B6t_E0ENcNtB12_5Right0EEEs_0CsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB13_IB13_Ahj20_Ahj1_EIB13_INtNtCsdZExvAaxgia_5alloc3vec3VechEB1N_EEIB13_B1T_B1T_EEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainINtNtB2X_3map3MapIB2T_IB3L_IB2T_IB3L_IB2T_NtNvNtB6_6leb1286encode10EncodeIterB4q_ENCINvB4_20delimited_tag_encodeB1H_E0EINtNtNtB2Z_7sources4once4OnceB1C_EENcNtB1x_4Left0EIB3L_INtNtB2X_7flatten7FlatMapINtNtB31_6option8IntoIterB1Y_EIB2T_IB3L_B4l_NCIB57_B1Y_E0EIB5G_B1T_EENCNCNvNtNtNtB8_7network5codec13block_request20build_block_response0s_0ENcNtB1x_5Right0EENcNtB12_4Left0EIB3L_IB2T_IB3L_IB6z_IB6z_IB6Y_IB1Z_B1Y_EEINtNtB21_9into_iter8IntoIterB1Y_ENCB86_s0_0EB7r_NCB86_s1_0ENcNtB2D_4Left0EIB3L_IB6z_B6X_B7r_NCB86_s2_0ENcNtB2D_5Right0EENcNtB12_5Right0EEEs_0CsiUjFBJteJ7x_17smoldot_full_node
66
0
        .chain(iter::once(either::Left(inner_message)))
67
0
}
Unexecuted instantiation: _RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf18message_tag_encodeppEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB11_Ahj20_Ahj1_EIB11_IB11_INtNvB2_17string_tag_encode7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEB1G_EIB11_INtNtB2A_3vec3VechEB1G_EEEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainIB3J_INtNtB3N_3map3MapIB3J_IB4G_IB3J_NtNvNtB4_6leb1286encode10EncodeIterB5b_ENCINvB2_20delimited_tag_encodeB1A_E0EINtNtNtB3P_7sources4once4OnceB1v_EENcNtB10_4Left0EIB4G_IB4G_IB3J_IB4G_B56_NCIB5S_B1W_E0EIB6r_B1R_EENcNtB1M_4Left0ENcNtB10_5Right0EEIB4G_IB4G_IB3J_IB4G_B56_NCIB5S_B3i_E0EIB6r_B3d_EENcNtB1M_5Right0EB8g_EEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB11_Ahj20_Ahj1_EIB11_INtNtCsdZExvAaxgia_5alloc3vec3VechEB1G_EEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainINtNtB2B_3map3MapIB2x_IB3p_IB2x_NtNvNtB4_6leb1286encode10EncodeIterB3U_ENCINvB2_20delimited_tag_encodeB1A_E0EINtNtNtB2D_7sources4once4OnceB1v_EENcNtB10_4Left0EIB3p_INtNtB2B_7flatten7FlatMapINtNtB1U_9into_iter8IntoIterB1R_EIB2x_IB3p_B3P_NCIB4B_B1R_E0EIB5a_B1M_EENCINvNtNtNtB6_7network5codec18storage_call_proof27build_storage_proof_requestB1R_B6r_E0ENcNtB10_5Right0EEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeppEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB11_Ahj20_Ahj1_EIB11_IB11_INtNvB2_17string_tag_encode7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEB1G_EIB11_INtNtB2A_3vec3VechEB1G_EEEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainIB3J_INtNtB3N_3map3MapIB3J_IB4G_IB3J_NtNvNtB4_6leb1286encode10EncodeIterB5b_ENCINvB2_20delimited_tag_encodeB1A_E0EINtNtNtB3P_7sources4once4OnceB1v_EENcNtB10_4Left0EIB4G_IB4G_IB3J_IB4G_B56_NCIB5S_B1W_E0EIB6r_B1R_EENcNtB1M_4Left0ENcNtB10_5Right0EEIB4G_IB4G_IB3J_IB4G_B56_NCIB5S_B3i_E0EIB6r_B3d_EENcNtB1M_5Right0EB8g_EEECsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB11_Ahj20_Ahj1_EIB11_INtNtCsdZExvAaxgia_5alloc3vec3VechEB1G_EEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainINtNtB2B_3map3MapIB2x_IB3p_IB2x_NtNvNtB4_6leb1286encode10EncodeIterB3U_ENCINvB2_20delimited_tag_encodeB1A_E0EINtNtNtB2D_7sources4once4OnceB1v_EENcNtB10_4Left0EIB3p_INtNtB2B_7flatten7FlatMapINtNtB1U_9into_iter8IntoIterB1R_EIB2x_IB3p_B3P_NCIB4B_B1R_E0EIB5a_B1M_EENCINvNtNtNtB6_7network5codec18storage_call_proof27build_storage_proof_requestB1R_B6r_E0ENcNtB10_5Right0EEECsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_encodeINtCs1qmLyiTSqYF_6either6EitherIB11_IB11_Ahj20_Ahj1_EIB11_INtNtCsdZExvAaxgia_5alloc3vec3VechEB1L_EEIB11_B1R_B1R_EEINtNtNtNtCsaYZPK01V26L_4core4iter8adapters5chain5ChainINtNtB2V_3map3MapIB2R_IB3J_IB2R_IB3J_IB2R_NtNvNtB4_6leb1286encode10EncodeIterB4o_ENCINvB2_20delimited_tag_encodeB1F_E0EINtNtNtB2X_7sources4once4OnceB1A_EENcNtB1v_4Left0EIB3J_INtNtB2V_7flatten7FlatMapINtNtB2Z_6option8IntoIterB1W_EIB2R_IB3J_B4j_NCIB55_B1W_E0EIB5E_B1R_EENCNCNvNtNtNtB6_7network5codec13block_request20build_block_response0s_0ENcNtB1v_5Right0EENcNtB10_4Left0EIB3J_IB2R_IB3J_IB6x_IB6x_IB6W_IB1X_B1W_EEINtNtB1Z_9into_iter8IntoIterB1W_ENCB84_s0_0EB7p_NCB84_s1_0ENcNtB2B_4Left0EIB3J_IB6x_B6V_B7p_NCB84_s2_0ENcNtB2B_5Right0EENcNtB10_5Right0EEECsiUjFBJteJ7x_17smoldot_full_node
68
69
312
pub(crate) fn bytes_tag_encode<'a>(
70
312
    field: u64,
71
312
    data: impl AsRef<[u8]> + Clone + 'a,
72
312
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
73
312
    // Protobuf only allows 2 GiB of data.
74
312
    debug_assert!(data.as_ref().len() <= 2 * 1024 * 1024 * 1024);
75
312
    delimited_tag_encode(field, data)
76
312
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf16bytes_tag_encodeINtNvB2_17string_tag_encode7WrapperReEEB6_
Line
Count
Source
69
1
pub(crate) fn bytes_tag_encode<'a>(
70
1
    field: u64,
71
1
    data: impl AsRef<[u8]> + Clone + 'a,
72
1
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
73
1
    // Protobuf only allows 2 GiB of data.
74
1
    debug_assert!(data.as_ref().len() <= 2 * 1024 * 1024 * 1024);
75
1
    delimited_tag_encode(field, data)
76
1
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf16bytes_tag_encodeRAhj20_EB6_
Line
Count
Source
69
53
pub(crate) fn bytes_tag_encode<'a>(
70
53
    field: u64,
71
53
    data: impl AsRef<[u8]> + Clone + 'a,
72
53
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
73
53
    // Protobuf only allows 2 GiB of data.
74
53
    debug_assert!(data.as_ref().len() <= 2 * 1024 * 1024 * 1024);
75
53
    delimited_tag_encode(field, data)
76
53
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf16bytes_tag_encodeRAhj40_EB6_
Line
Count
Source
69
24
pub(crate) fn bytes_tag_encode<'a>(
70
24
    field: u64,
71
24
    data: impl AsRef<[u8]> + Clone + 'a,
72
24
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
73
24
    // Protobuf only allows 2 GiB of data.
74
24
    debug_assert!(data.as_ref().len() <= 2 * 1024 * 1024 * 1024);
75
24
    delimited_tag_encode(field, data)
76
24
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf16bytes_tag_encodeRAhj4_EB6_
Line
Count
Source
69
1
pub(crate) fn bytes_tag_encode<'a>(
70
1
    field: u64,
71
1
    data: impl AsRef<[u8]> + Clone + 'a,
72
1
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
73
1
    // Protobuf only allows 2 GiB of data.
74
1
    debug_assert!(data.as_ref().len() <= 2 * 1024 * 1024 * 1024);
75
1
    delimited_tag_encode(field, data)
76
1
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf16bytes_tag_encodeRINtNtCsdZExvAaxgia_5alloc3vec3VechEEB6_
Line
Count
Source
69
24
pub(crate) fn bytes_tag_encode<'a>(
70
24
    field: u64,
71
24
    data: impl AsRef<[u8]> + Clone + 'a,
72
24
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
73
24
    // Protobuf only allows 2 GiB of data.
74
24
    debug_assert!(data.as_ref().len() <= 2 * 1024 * 1024 * 1024);
75
24
    delimited_tag_encode(field, data)
76
24
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeAhj20_ECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeINtNtCsdZExvAaxgia_5alloc3vec3VechEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeINtNvB2_17string_tag_encode7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeINtNvB2_17string_tag_encode7WrapperReEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeRShECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeAhj20_EB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeINtNtCsdZExvAaxgia_5alloc3vec3VechEEB6_
_RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeRAhj20_EB6_
Line
Count
Source
69
167
pub(crate) fn bytes_tag_encode<'a>(
70
167
    field: u64,
71
167
    data: impl AsRef<[u8]> + Clone + 'a,
72
167
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
73
167
    // Protobuf only allows 2 GiB of data.
74
167
    debug_assert!(data.as_ref().len() <= 2 * 1024 * 1024 * 1024);
75
167
    delimited_tag_encode(field, data)
76
167
}
_RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeRAhj40_EB6_
Line
Count
Source
69
21
pub(crate) fn bytes_tag_encode<'a>(
70
21
    field: u64,
71
21
    data: impl AsRef<[u8]> + Clone + 'a,
72
21
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
73
21
    // Protobuf only allows 2 GiB of data.
74
21
    debug_assert!(data.as_ref().len() <= 2 * 1024 * 1024 * 1024);
75
21
    delimited_tag_encode(field, data)
76
21
}
_RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeRINtNtCsdZExvAaxgia_5alloc3vec3VechEEB6_
Line
Count
Source
69
21
pub(crate) fn bytes_tag_encode<'a>(
70
21
    field: u64,
71
21
    data: impl AsRef<[u8]> + Clone + 'a,
72
21
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
73
21
    // Protobuf only allows 2 GiB of data.
74
21
    debug_assert!(data.as_ref().len() <= 2 * 1024 * 1024 * 1024);
75
21
    delimited_tag_encode(field, data)
76
21
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeRShEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeAhj20_ECsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeINtNtCsdZExvAaxgia_5alloc3vec3VechEECsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeINtNvB2_17string_tag_encode7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEECsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeINtNvB2_17string_tag_encode7WrapperReEECsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_encodeRShECsiUjFBJteJ7x_17smoldot_full_node
77
78
1
pub(crate) fn string_tag_encode<'a>(
79
1
    field: u64,
80
1
    data: impl AsRef<str> + Clone + 'a,
81
1
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
82
1
    #[derive(Clone)]
83
1
    struct Wrapper<T>(T);
84
1
    impl<T: AsRef<str>> AsRef<[u8]> for Wrapper<T> {
85
3
        fn as_ref(&self) -> &[u8] {
86
3
            self.0.as_ref().as_bytes()
87
3
        }
_RNvXNvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf17string_tag_encodeINtB2_7WrapperReEINtNtCsaYZPK01V26L_4core7convert5AsRefShE6as_refB8_
Line
Count
Source
85
3
        fn as_ref(&self) -> &[u8] {
86
3
            self.0.as_ref().as_bytes()
87
3
        }
Unexecuted instantiation: _RNvXNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17string_tag_encodeINtB2_7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEINtNtCsaYZPK01V26L_4core7convert5AsRefShE6as_refCsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNvXNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17string_tag_encodeINtB2_7WrapperReEINtNtCsaYZPK01V26L_4core7convert5AsRefShE6as_refCsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNvXININvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17string_tag_encode0pEINtB5_7WrapperpEINtNtCsaYZPK01V26L_4core7convert5AsRefShE6as_refBb_
Unexecuted instantiation: _RNvXNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17string_tag_encodeINtB2_7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEINtNtCsaYZPK01V26L_4core7convert5AsRefShE6as_refCsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RNvXNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17string_tag_encodeINtB2_7WrapperReEINtNtCsaYZPK01V26L_4core7convert5AsRefShE6as_refCsiUjFBJteJ7x_17smoldot_full_node
88
1
    }
89
1
90
1
    bytes_tag_encode(field, Wrapper(data))
91
1
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf17string_tag_encodeReEB6_
Line
Count
Source
78
1
pub(crate) fn string_tag_encode<'a>(
79
1
    field: u64,
80
1
    data: impl AsRef<str> + Clone + 'a,
81
1
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
82
1
    #[derive(Clone)]
83
1
    struct Wrapper<T>(T);
84
1
    impl<T: AsRef<str>> AsRef<[u8]> for Wrapper<T> {
85
1
        fn as_ref(&self) -> &[u8] {
86
1
            self.0.as_ref().as_bytes()
87
1
        }
88
1
    }
89
1
90
1
    bytes_tag_encode(field, Wrapper(data))
91
1
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17string_tag_encodeINtNtCsdZExvAaxgia_5alloc6borrow3CoweEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17string_tag_encodeReECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17string_tag_encodepEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17string_tag_encodeReECsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17string_tag_encodeINtNtCsdZExvAaxgia_5alloc6borrow3CoweEECsiUjFBJteJ7x_17smoldot_full_node
92
93
535
pub(crate) fn tag_encode(field: u64, wire_ty: u8) -> impl Iterator<Item = u8> + Clone {
94
535
    leb128::encode((field << 3) | u64::from(wire_ty))
95
535
}
_RNvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf10tag_encode
Line
Count
Source
93
159
pub(crate) fn tag_encode(field: u64, wire_ty: u8) -> impl Iterator<Item = u8> + Clone {
94
159
    leb128::encode((field << 3) | u64::from(wire_ty))
95
159
}
_RNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf10tag_encode
Line
Count
Source
93
376
pub(crate) fn tag_encode(field: u64, wire_ty: u8) -> impl Iterator<Item = u8> + Clone {
94
376
    leb128::encode((field << 3) | u64::from(wire_ty))
95
376
}
96
97
223
pub(crate) fn varint_zigzag_tag_encode(field: u64, value: u64) -> impl Iterator<Item = u8> + Clone {
98
223
    tag_encode(field, 0).chain(leb128::encode(value))
99
223
}
_RNvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf24varint_zigzag_tag_encode
Line
Count
Source
97
56
pub(crate) fn varint_zigzag_tag_encode(field: u64, value: u64) -> impl Iterator<Item = u8> + Clone {
98
56
    tag_encode(field, 0).chain(leb128::encode(value))
99
56
}
_RNvNtNtCseuYC0Zibziv_7smoldot4util8protobuf24varint_zigzag_tag_encode
Line
Count
Source
97
167
pub(crate) fn varint_zigzag_tag_encode(field: u64, value: u64) -> impl Iterator<Item = u8> + Clone {
98
167
    tag_encode(field, 0).chain(leb128::encode(value))
99
167
}
100
101
312
pub(crate) fn delimited_tag_encode<'a>(
102
312
    field: u64,
103
312
    data: impl AsRef<[u8]> + Clone + 'a,
104
312
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
105
312
    tag_encode(field, 2)
106
312
        .chain(leb128::encode_usize(data.as_ref().len()))
107
625
        .map(|v| either::Right([v]))
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_encodeRAhj20_E0B8_
Line
Count
Source
107
106
        .map(|v| either::Right([v]))
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_encodeRAhj40_E0B8_
Line
Count
Source
107
48
        .map(|v| either::Right([v]))
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_encodeRINtNtCsdZExvAaxgia_5alloc3vec3VechEE0B8_
Line
Count
Source
107
48
        .map(|v| either::Right([v]))
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_encodeINtNvB4_17string_tag_encode7WrapperReEE0B8_
Line
Count
Source
107
3
        .map(|v| either::Right([v]))
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_encodeRAhj4_E0B8_
Line
Count
Source
107
2
        .map(|v| either::Right([v]))
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeAhj20_E0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeINtNtCsdZExvAaxgia_5alloc3vec3VechEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeINtNvB4_17string_tag_encode7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeINtNvB4_17string_tag_encode7WrapperReEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeRShE0CsDDUKWWCHAU_18smoldot_light_wasm
_RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeRAhj20_E0B8_
Line
Count
Source
107
334
        .map(|v| either::Right([v]))
_RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeRAhj40_E0B8_
Line
Count
Source
107
42
        .map(|v| either::Right([v]))
_RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeRINtNtCsdZExvAaxgia_5alloc3vec3VechEE0B8_
Line
Count
Source
107
42
        .map(|v| either::Right([v]))
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeRShE0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeAhj20_E0CsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeINtNtCsdZExvAaxgia_5alloc3vec3VechEE0CsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeINtNvB4_17string_tag_encode7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEE0CsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeINtNvB4_17string_tag_encode7WrapperReEE0CsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeRShE0CsiUjFBJteJ7x_17smoldot_full_node
108
312
        .chain(iter::once(either::Left(data)))
109
312
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_encodeINtNvB2_17string_tag_encode7WrapperReEEB6_
Line
Count
Source
101
1
pub(crate) fn delimited_tag_encode<'a>(
102
1
    field: u64,
103
1
    data: impl AsRef<[u8]> + Clone + 'a,
104
1
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
105
1
    tag_encode(field, 2)
106
1
        .chain(leb128::encode_usize(data.as_ref().len()))
107
1
        .map(|v| either::Right([v]))
108
1
        .chain(iter::once(either::Left(data)))
109
1
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_encodeRAhj20_EB6_
Line
Count
Source
101
53
pub(crate) fn delimited_tag_encode<'a>(
102
53
    field: u64,
103
53
    data: impl AsRef<[u8]> + Clone + 'a,
104
53
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
105
53
    tag_encode(field, 2)
106
53
        .chain(leb128::encode_usize(data.as_ref().len()))
107
53
        .map(|v| either::Right([v]))
108
53
        .chain(iter::once(either::Left(data)))
109
53
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_encodeRAhj40_EB6_
Line
Count
Source
101
24
pub(crate) fn delimited_tag_encode<'a>(
102
24
    field: u64,
103
24
    data: impl AsRef<[u8]> + Clone + 'a,
104
24
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
105
24
    tag_encode(field, 2)
106
24
        .chain(leb128::encode_usize(data.as_ref().len()))
107
24
        .map(|v| either::Right([v]))
108
24
        .chain(iter::once(either::Left(data)))
109
24
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_encodeRAhj4_EB6_
Line
Count
Source
101
1
pub(crate) fn delimited_tag_encode<'a>(
102
1
    field: u64,
103
1
    data: impl AsRef<[u8]> + Clone + 'a,
104
1
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
105
1
    tag_encode(field, 2)
106
1
        .chain(leb128::encode_usize(data.as_ref().len()))
107
1
        .map(|v| either::Right([v]))
108
1
        .chain(iter::once(either::Left(data)))
109
1
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_encodeRINtNtCsdZExvAaxgia_5alloc3vec3VechEEB6_
Line
Count
Source
101
24
pub(crate) fn delimited_tag_encode<'a>(
102
24
    field: u64,
103
24
    data: impl AsRef<[u8]> + Clone + 'a,
104
24
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
105
24
    tag_encode(field, 2)
106
24
        .chain(leb128::encode_usize(data.as_ref().len()))
107
24
        .map(|v| either::Right([v]))
108
24
        .chain(iter::once(either::Left(data)))
109
24
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeAhj20_ECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeINtNtCsdZExvAaxgia_5alloc3vec3VechEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeINtNvB2_17string_tag_encode7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeINtNvB2_17string_tag_encode7WrapperReEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeRShECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeAhj20_EB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeINtNtCsdZExvAaxgia_5alloc3vec3VechEEB6_
_RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeRAhj20_EB6_
Line
Count
Source
101
167
pub(crate) fn delimited_tag_encode<'a>(
102
167
    field: u64,
103
167
    data: impl AsRef<[u8]> + Clone + 'a,
104
167
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
105
167
    tag_encode(field, 2)
106
167
        .chain(leb128::encode_usize(data.as_ref().len()))
107
167
        .map(|v| either::Right([v]))
108
167
        .chain(iter::once(either::Left(data)))
109
167
}
_RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeRAhj40_EB6_
Line
Count
Source
101
21
pub(crate) fn delimited_tag_encode<'a>(
102
21
    field: u64,
103
21
    data: impl AsRef<[u8]> + Clone + 'a,
104
21
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
105
21
    tag_encode(field, 2)
106
21
        .chain(leb128::encode_usize(data.as_ref().len()))
107
21
        .map(|v| either::Right([v]))
108
21
        .chain(iter::once(either::Left(data)))
109
21
}
_RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeRINtNtCsdZExvAaxgia_5alloc3vec3VechEEB6_
Line
Count
Source
101
21
pub(crate) fn delimited_tag_encode<'a>(
102
21
    field: u64,
103
21
    data: impl AsRef<[u8]> + Clone + 'a,
104
21
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
105
21
    tag_encode(field, 2)
106
21
        .chain(leb128::encode_usize(data.as_ref().len()))
107
21
        .map(|v| either::Right([v]))
108
21
        .chain(iter::once(either::Left(data)))
109
21
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeRShEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeAhj20_ECsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeINtNtCsdZExvAaxgia_5alloc3vec3VechEECsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeINtNvB2_17string_tag_encode7WrapperINtNtCsdZExvAaxgia_5alloc6borrow3CoweEEECsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeINtNvB2_17string_tag_encode7WrapperReEECsiUjFBJteJ7x_17smoldot_full_node
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_encodeRShECsiUjFBJteJ7x_17smoldot_full_node
110
111
/// Decodes a Protobuf tag. On success, returns the field number and wire type.
112
264
pub(crate) fn tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
113
264
    bytes: &'a [u8],
114
264
) -> nom::IResult<&'a [u8], (u64, u8), E> {
115
264
    nom::combinator::map(leb128::nom_leb128_u64, |num| {
116
263
        let wire_ty = u8::try_from(num & 0b111).unwrap();
117
263
        let field = num >> 3;
118
263
        (field, wire_ty)
119
264
    })(bytes)
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf10tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0B8_
Line
Count
Source
115
96
    nom::combinator::map(leb128::nom_leb128_u64, |num| {
116
96
        let wire_ty = u8::try_from(num & 0b111).unwrap();
117
96
        let field = num >> 3;
118
96
        (field, wire_ty)
119
96
    })(bytes)
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf10tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
Line
Count
Source
115
59
    nom::combinator::map(leb128::nom_leb128_u64, |num| {
116
59
        let wire_ty = u8::try_from(num & 0b111).unwrap();
117
59
        let field = num >> 3;
118
59
        (field, wire_ty)
119
59
    })(bytes)
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf10tag_decodeNtNvMNtNtB8_6libp2p7peer_idNtBY_9PublicKey22from_protobuf_encoding12ErrorWrapperE0B8_
Line
Count
Source
115
108
    nom::combinator::map(leb128::nom_leb128_u64, |num| {
116
108
        let wire_ty = u8::try_from(num & 0b111).unwrap();
117
108
        let field = num >> 3;
118
108
        (field, wire_ty)
119
108
    })(bytes)
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf10tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf10tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf10tag_decodeNtNvMNtNtB8_6libp2p7peer_idNtBZ_9PublicKey22from_protobuf_encoding12ErrorWrapperE0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf10tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf10tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0CsiUjFBJteJ7x_17smoldot_full_node
120
264
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf10tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEEB6_
Line
Count
Source
112
96
pub(crate) fn tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
113
96
    bytes: &'a [u8],
114
96
) -> nom::IResult<&'a [u8], (u64, u8), E> {
115
96
    nom::combinator::map(leb128::nom_leb128_u64, |num| {
116
        let wire_ty = u8::try_from(num & 0b111).unwrap();
117
        let field = num >> 3;
118
        (field, wire_ty)
119
96
    })(bytes)
120
96
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf10tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Line
Count
Source
112
60
pub(crate) fn tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
113
60
    bytes: &'a [u8],
114
60
) -> nom::IResult<&'a [u8], (u64, u8), E> {
115
60
    nom::combinator::map(leb128::nom_leb128_u64, |num| {
116
        let wire_ty = u8::try_from(num & 0b111).unwrap();
117
        let field = num >> 3;
118
        (field, wire_ty)
119
60
    })(bytes)
120
60
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf10tag_decodeNtNvMNtNtB6_6libp2p7peer_idNtBW_9PublicKey22from_protobuf_encoding12ErrorWrapperEB6_
Line
Count
Source
112
108
pub(crate) fn tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
113
108
    bytes: &'a [u8],
114
108
) -> nom::IResult<&'a [u8], (u64, u8), E> {
115
108
    nom::combinator::map(leb128::nom_leb128_u64, |num| {
116
        let wire_ty = u8::try_from(num & 0b111).unwrap();
117
        let field = num >> 3;
118
        (field, wire_ty)
119
108
    })(bytes)
120
108
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf10tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf10tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf10tag_decodeNtNvMNtNtB6_6libp2p7peer_idNtBX_9PublicKey22from_protobuf_encoding12ErrorWrapperEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf10tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf10tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEECsiUjFBJteJ7x_17smoldot_full_node
121
122
/// Decodes a Protobuf tag of the given field number, and value where the data type is `uint32`.
123
3
pub(crate) fn uint32_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
124
3
    bytes: &'a [u8],
125
3
) -> nom::IResult<&'a [u8], u32, E> {
126
3
    nom::combinator::map_opt(varint_zigzag_tag_decode, |num| u32::try_from(num).ok())(bytes)
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf17uint32_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
Line
Count
Source
126
3
    nom::combinator::map_opt(varint_zigzag_tag_decode, |num| u32::try_from(num).ok())(bytes)
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17uint32_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
127
3
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf17uint32_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Line
Count
Source
123
3
pub(crate) fn uint32_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
124
3
    bytes: &'a [u8],
125
3
) -> nom::IResult<&'a [u8], u32, E> {
126
3
    nom::combinator::map_opt(varint_zigzag_tag_decode, |num| u32::try_from(num).ok())(bytes)
127
3
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17uint32_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
128
129
/// Decodes a Protobuf tag and value where the data type is `bool`.
130
///
131
/// > **Note**: The implementation decodes any non-zero value as `true`, meaning that multiple
132
/// >           different encoded messages can be decoded to `true`. This is important to take
133
/// >           into consideration if determinism is desired.
134
1
pub(crate) fn bool_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
135
1
    bytes: &'a [u8],
136
1
) -> nom::IResult<&'a [u8], bool, E> {
137
1
    nom::combinator::map(varint_zigzag_tag_decode, |n| {
138
1
        // Note that booleans are undocumented. However, the official Java library interprets
139
1
        // 0 as false and any other value as true.
140
1
        // See <https://github.com/protocolbuffers/protobuf/blob/520c601c99012101c816b6ccc89e8d6fc28fdbb8/java/core/src/main/java/com/google/protobuf/BinaryReader.java#L206>
141
1
        // or <https://github.com/protocolbuffers/protobuf/blob/520c601c99012101c816b6ccc89e8d6fc28fdbb8/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L788>
142
1
        n != 0
143
1
    })(bytes)
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf15bool_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
Line
Count
Source
137
1
    nom::combinator::map(varint_zigzag_tag_decode, |n| {
138
1
        // Note that booleans are undocumented. However, the official Java library interprets
139
1
        // 0 as false and any other value as true.
140
1
        // See <https://github.com/protocolbuffers/protobuf/blob/520c601c99012101c816b6ccc89e8d6fc28fdbb8/java/core/src/main/java/com/google/protobuf/BinaryReader.java#L206>
141
1
        // or <https://github.com/protocolbuffers/protobuf/blob/520c601c99012101c816b6ccc89e8d6fc28fdbb8/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L788>
142
1
        n != 0
143
1
    })(bytes)
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf15bool_tag_decodepE0B8_
144
1
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf15bool_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Line
Count
Source
134
1
pub(crate) fn bool_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
135
1
    bytes: &'a [u8],
136
1
) -> nom::IResult<&'a [u8], bool, E> {
137
1
    nom::combinator::map(varint_zigzag_tag_decode, |n| {
138
        // Note that booleans are undocumented. However, the official Java library interprets
139
        // 0 as false and any other value as true.
140
        // See <https://github.com/protocolbuffers/protobuf/blob/520c601c99012101c816b6ccc89e8d6fc28fdbb8/java/core/src/main/java/com/google/protobuf/BinaryReader.java#L206>
141
        // or <https://github.com/protocolbuffers/protobuf/blob/520c601c99012101c816b6ccc89e8d6fc28fdbb8/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L788>
142
        n != 0
143
1
    })(bytes)
144
1
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf15bool_tag_decodepEB6_
145
146
/// Decodes a Protobuf tag and value where the data type is "enum".
147
28
pub(crate) fn enum_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
148
28
    bytes: &'a [u8],
149
28
) -> nom::IResult<&'a [u8], u64, E> {
150
28
    varint_zigzag_tag_decode(bytes)
151
28
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf15enum_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Line
Count
Source
147
1
pub(crate) fn enum_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
148
1
    bytes: &'a [u8],
149
1
) -> nom::IResult<&'a [u8], u64, E> {
150
1
    varint_zigzag_tag_decode(bytes)
151
1
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf15enum_tag_decodeNtNvMNtNtB6_6libp2p7peer_idNtB11_9PublicKey22from_protobuf_encoding12ErrorWrapperEB6_
Line
Count
Source
147
27
pub(crate) fn enum_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
148
27
    bytes: &'a [u8],
149
27
) -> nom::IResult<&'a [u8], u64, E> {
150
27
    varint_zigzag_tag_decode(bytes)
151
27
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf15enum_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf15enum_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf15enum_tag_decodeNtNvMNtNtB6_6libp2p7peer_idNtB12_9PublicKey22from_protobuf_encoding12ErrorWrapperEB6_
152
153
/// Decodes a Protobuf tag and value where the data type is a sub-message.
154
1
pub(crate) fn message_tag_decode<'a, O, E: nom::error::ParseError<&'a [u8]>>(
155
1
    inner_message_parser: impl FnMut(&'a [u8]) -> nom::IResult<&'a [u8], O, E>,
156
1
) -> impl FnMut(&'a [u8]) -> nom::IResult<&'a [u8], O, E> {
157
1
    nom::combinator::map_parser(delimited_tag_decode, inner_message_parser)
158
1
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf18message_tag_decodeINtNCNvNtNtNtB6_7network5codec13block_request21decode_block_responses0_03OutRShINtNtCsaYZPK01V26L_4core6option6OptionB2d_EINtNtCsdZExvAaxgia_5alloc3vec3VecB2d_EB2g_EINtNtCs6ga8gEqbpRc_3nom5error5ErrorB2d_ENCB12_0EB6_
Line
Count
Source
154
1
pub(crate) fn message_tag_decode<'a, O, E: nom::error::ParseError<&'a [u8]>>(
155
1
    inner_message_parser: impl FnMut(&'a [u8]) -> nom::IResult<&'a [u8], O, E>,
156
1
) -> impl FnMut(&'a [u8]) -> nom::IResult<&'a [u8], O, E> {
157
1
    nom::combinator::map_parser(delimited_tag_decode, inner_message_parser)
158
1
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_decodeINtNCNvNtNtNtB6_7network5codec8kademlia25decode_find_node_responses_03OutRShINtNtCsdZExvAaxgia_5alloc3vec3VecB2b_EEINtNtCs6ga8gEqbpRc_3nom5error5ErrorB2b_ENCB13_0EB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_decodeINtNCNvNtNtNtB6_7network5codec13block_request21decode_block_responses0_03OutRShINtNtCsaYZPK01V26L_4core6option6OptionB2e_EINtNtCsdZExvAaxgia_5alloc3vec3VecB2e_EB2h_EINtNtCs6ga8gEqbpRc_3nom5error5ErrorB2e_ENCB13_0EB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf18message_tag_decodeINtNCNvNtNtNtB6_7network5codec18storage_call_proof37decode_storage_or_call_proof_responses_03OutINtNtCsaYZPK01V26L_4core6option6OptionRShEEINtNtCs6ga8gEqbpRc_3nom5error5ErrorB3a_ENCB13_0EB6_
159
160
/// Decodes a Protobuf tag and value where the data type is "string".
161
1
pub(crate) fn string_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
162
1
    bytes: &'a [u8],
163
1
) -> nom::IResult<&'a [u8], &'a str, E> {
164
1
    nom::combinator::map_opt(delimited_tag_decode, |bytes| {
165
1
        if bytes.len() > 2 * 1024 * 1024 * 1024 {
166
0
            return None;
167
1
        }
168
1
        str::from_utf8(bytes).ok()
169
1
    })(bytes)
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf17string_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
Line
Count
Source
164
1
    nom::combinator::map_opt(delimited_tag_decode, |bytes| {
165
1
        if bytes.len() > 2 * 1024 * 1024 * 1024 {
166
0
            return None;
167
1
        }
168
1
        str::from_utf8(bytes).ok()
169
1
    })(bytes)
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17string_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
170
1
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf17string_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Line
Count
Source
161
1
pub(crate) fn string_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
162
1
    bytes: &'a [u8],
163
1
) -> nom::IResult<&'a [u8], &'a str, E> {
164
1
    nom::combinator::map_opt(delimited_tag_decode, |bytes| {
165
        if bytes.len() > 2 * 1024 * 1024 * 1024 {
166
            return None;
167
        }
168
        str::from_utf8(bytes).ok()
169
1
    })(bytes)
170
1
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf17string_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
171
172
/// Decodes a Protobuf tag and value where the data type is "bytes".
173
80
pub(crate) fn bytes_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
174
80
    bytes: &'a [u8],
175
80
) -> nom::IResult<&'a [u8], &'a [u8], E> {
176
80
    nom::combinator::verify(delimited_tag_decode, |bytes: &[u8]| {
177
79
        bytes.len() <= 2 * 1024 * 1024 * 1024
178
80
    })(bytes)
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf16bytes_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
Line
Count
Source
176
4
    nom::combinator::verify(delimited_tag_decode, |bytes: &[u8]| {
177
4
        bytes.len() <= 2 * 1024 * 1024 * 1024
178
4
    })(bytes)
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf16bytes_tag_decodeNtNvMNtNtB8_6libp2p7peer_idNtB14_9PublicKey22from_protobuf_encoding12ErrorWrapperE0B8_
Line
Count
Source
176
27
    nom::combinator::verify(delimited_tag_decode, |bytes: &[u8]| {
177
27
        bytes.len() <= 2 * 1024 * 1024 * 1024
178
27
    })(bytes)
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf16bytes_tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0B8_
Line
Count
Source
176
48
    nom::combinator::verify(delimited_tag_decode, |bytes: &[u8]| {
177
48
        bytes.len() <= 2 * 1024 * 1024 * 1024
178
48
    })(bytes)
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_decodeNtNvMNtNtB8_6libp2p7peer_idNtB15_9PublicKey22from_protobuf_encoding12ErrorWrapperE0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0CsiUjFBJteJ7x_17smoldot_full_node
179
80
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf16bytes_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Line
Count
Source
173
5
pub(crate) fn bytes_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
174
5
    bytes: &'a [u8],
175
5
) -> nom::IResult<&'a [u8], &'a [u8], E> {
176
5
    nom::combinator::verify(delimited_tag_decode, |bytes: &[u8]| {
177
        bytes.len() <= 2 * 1024 * 1024 * 1024
178
5
    })(bytes)
179
5
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf16bytes_tag_decodeNtNvMNtNtB6_6libp2p7peer_idNtB12_9PublicKey22from_protobuf_encoding12ErrorWrapperEB6_
Line
Count
Source
173
27
pub(crate) fn bytes_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
174
27
    bytes: &'a [u8],
175
27
) -> nom::IResult<&'a [u8], &'a [u8], E> {
176
27
    nom::combinator::verify(delimited_tag_decode, |bytes: &[u8]| {
177
        bytes.len() <= 2 * 1024 * 1024 * 1024
178
27
    })(bytes)
179
27
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf16bytes_tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEEB6_
Line
Count
Source
173
48
pub(crate) fn bytes_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
174
48
    bytes: &'a [u8],
175
48
) -> nom::IResult<&'a [u8], &'a [u8], E> {
176
48
    nom::combinator::verify(delimited_tag_decode, |bytes: &[u8]| {
177
        bytes.len() <= 2 * 1024 * 1024 * 1024
178
48
    })(bytes)
179
48
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_decodeNtNvMNtNtB6_6libp2p7peer_idNtB13_9PublicKey22from_protobuf_encoding12ErrorWrapperEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf16bytes_tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEECsiUjFBJteJ7x_17smoldot_full_node
180
181
/// Decodes a Protobuf tag  and value where the wire type is `varint` or "zigzag".
182
32
pub(crate) fn varint_zigzag_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
183
32
    bytes: &'a [u8],
184
32
) -> nom::IResult<&'a [u8], u64, E> {
185
32
    nom::sequence::preceded(
186
32
        nom::combinator::verify(tag_decode, move |(_, ty)| *ty == 0),
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf24varint_zigzag_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
Line
Count
Source
186
5
        nom::combinator::verify(tag_decode, move |(_, ty)| *ty == 0),
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf24varint_zigzag_tag_decodeNtNvMNtNtB8_6libp2p7peer_idNtB1c_9PublicKey22from_protobuf_encoding12ErrorWrapperE0B8_
Line
Count
Source
186
27
        nom::combinator::verify(tag_decode, move |(_, ty)| *ty == 0),
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf24varint_zigzag_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf24varint_zigzag_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf24varint_zigzag_tag_decodeNtNvMNtNtB8_6libp2p7peer_idNtB1d_9PublicKey22from_protobuf_encoding12ErrorWrapperE0B8_
187
32
        leb128::nom_leb128_u64,
188
32
    )(bytes)
189
32
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf24varint_zigzag_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Line
Count
Source
182
5
pub(crate) fn varint_zigzag_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
183
5
    bytes: &'a [u8],
184
5
) -> nom::IResult<&'a [u8], u64, E> {
185
5
    nom::sequence::preceded(
186
5
        nom::combinator::verify(tag_decode, move |(_, ty)| *ty == 0),
187
5
        leb128::nom_leb128_u64,
188
5
    )(bytes)
189
5
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf24varint_zigzag_tag_decodeNtNvMNtNtB6_6libp2p7peer_idNtB1a_9PublicKey22from_protobuf_encoding12ErrorWrapperEB6_
Line
Count
Source
182
27
pub(crate) fn varint_zigzag_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
183
27
    bytes: &'a [u8],
184
27
) -> nom::IResult<&'a [u8], u64, E> {
185
27
    nom::sequence::preceded(
186
27
        nom::combinator::verify(tag_decode, move |(_, ty)| *ty == 0),
187
27
        leb128::nom_leb128_u64,
188
27
    )(bytes)
189
27
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf24varint_zigzag_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf24varint_zigzag_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf24varint_zigzag_tag_decodeNtNvMNtNtB6_6libp2p7peer_idNtB1b_9PublicKey22from_protobuf_encoding12ErrorWrapperEB6_
190
191
/// Decodes a Protobuf tag and value where the wire type is "delimited".
192
82
pub(crate) fn delimited_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
193
82
    bytes: &'a [u8],
194
82
) -> nom::IResult<&'a [u8], &'a [u8], E> {
195
82
    nom::sequence::preceded(
196
82
        nom::combinator::verify(tag_decode, move |(_, ty)| *ty == 2),
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
Line
Count
Source
196
7
        nom::combinator::verify(tag_decode, move |(_, ty)| *ty == 2),
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_decodeNtNvMNtNtB8_6libp2p7peer_idNtB18_9PublicKey22from_protobuf_encoding12ErrorWrapperE0B8_
Line
Count
Source
196
27
        nom::combinator::verify(tag_decode, move |(_, ty)| *ty == 2),
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0B8_
Line
Count
Source
196
48
        nom::combinator::verify(tag_decode, move |(_, ty)| *ty == 2),
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_decodeNtNvMNtNtB8_6libp2p7peer_idNtB19_9PublicKey22from_protobuf_encoding12ErrorWrapperE0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0CsiUjFBJteJ7x_17smoldot_full_node
197
82
        nom::multi::length_data(leb128::nom_leb128_usize),
198
82
    )(bytes)
199
82
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Line
Count
Source
192
7
pub(crate) fn delimited_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
193
7
    bytes: &'a [u8],
194
7
) -> nom::IResult<&'a [u8], &'a [u8], E> {
195
7
    nom::sequence::preceded(
196
7
        nom::combinator::verify(tag_decode, move |(_, ty)| *ty == 2),
197
7
        nom::multi::length_data(leb128::nom_leb128_usize),
198
7
    )(bytes)
199
7
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_decodeNtNvMNtNtB6_6libp2p7peer_idNtB16_9PublicKey22from_protobuf_encoding12ErrorWrapperEB6_
Line
Count
Source
192
27
pub(crate) fn delimited_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
193
27
    bytes: &'a [u8],
194
27
) -> nom::IResult<&'a [u8], &'a [u8], E> {
195
27
    nom::sequence::preceded(
196
27
        nom::combinator::verify(tag_decode, move |(_, ty)| *ty == 2),
197
27
        nom::multi::length_data(leb128::nom_leb128_usize),
198
27
    )(bytes)
199
27
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf20delimited_tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEEB6_
Line
Count
Source
192
48
pub(crate) fn delimited_tag_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
193
48
    bytes: &'a [u8],
194
48
) -> nom::IResult<&'a [u8], &'a [u8], E> {
195
48
    nom::sequence::preceded(
196
48
        nom::combinator::verify(tag_decode, move |(_, ty)| *ty == 2),
197
48
        nom::multi::length_data(leb128::nom_leb128_usize),
198
48
    )(bytes)
199
48
}
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_decodeNtNvMNtNtB6_6libp2p7peer_idNtB17_9PublicKey22from_protobuf_encoding12ErrorWrapperEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf20delimited_tag_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEECsiUjFBJteJ7x_17smoldot_full_node
200
201
/// Decodes a Protobuf tag and value and discards them.
202
21
pub(crate) fn tag_value_skip_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
203
21
    bytes: &'a [u8],
204
21
) -> nom::IResult<&'a [u8], (), E> {
205
21
    nom::combinator::flat_map(tag_decode, |(_, wire_ty)| 
{20
206
20
        move |inner_bytes| match wire_ty {
207
15
            0 => nom::combinator::map(leb128::nom_leb128_u64, |_| ())(inner_bytes),
_RNCNCNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE000Bc_
Line
Count
Source
207
15
            0 => nom::combinator::map(leb128::nom_leb128_u64, |_| ())(inner_bytes),
Unexecuted instantiation: _RNCNCNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE000Bc_
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE000CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE000CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE000Bc_
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE000CsiUjFBJteJ7x_17smoldot_full_node
208
0
            5 => nom::combinator::map(nom::bytes::streaming::take(4u32), |_| ())(inner_bytes),
Unexecuted instantiation: _RNCNCNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE00s_0Bc_
Unexecuted instantiation: _RNCNCNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00s_0Bc_
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE00s_0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00s_0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE00s_0Bc_
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00s_0CsiUjFBJteJ7x_17smoldot_full_node
209
3
            1 => nom::combinator::map(nom::bytes::streaming::take(8u32), |_| ())(inner_bytes),
_RNCNCNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE00s0_0Bc_
Line
Count
Source
209
3
            1 => nom::combinator::map(nom::bytes::streaming::take(8u32), |_| ())(inner_bytes),
Unexecuted instantiation: _RNCNCNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00s0_0Bc_
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE00s0_0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00s0_0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE00s0_0Bc_
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00s0_0CsiUjFBJteJ7x_17smoldot_full_node
210
2
            2 => nom::combinator::map(nom::multi::length_data(leb128::nom_leb128_usize), |_| ())(
_RNCNCNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE00s1_0Bc_
Line
Count
Source
210
2
            2 => nom::combinator::map(nom::multi::length_data(leb128::nom_leb128_usize), |_| ())(
Unexecuted instantiation: _RNCNCNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00s1_0Bc_
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE00s1_0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00s1_0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE00s1_0Bc_
Unexecuted instantiation: _RNCNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00s1_0CsiUjFBJteJ7x_17smoldot_full_node
211
2
                inner_bytes,
212
2
            ),
213
0
            _ => Err(nom::Err::Error(nom::error::ParseError::from_error_kind(
214
0
                bytes,
215
0
                nom::error::ErrorKind::Tag,
216
0
            ))),
217
20
        }
_RNCNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE00Ba_
Line
Count
Source
206
20
        move |inner_bytes| match wire_ty {
207
15
            0 => nom::combinator::map(leb128::nom_leb128_u64, |_| ())(inner_bytes),
208
0
            5 => nom::combinator::map(nom::bytes::streaming::take(4u32), |_| ())(inner_bytes),
209
3
            1 => nom::combinator::map(nom::bytes::streaming::take(8u32), |_| ())(inner_bytes),
210
2
            2 => nom::combinator::map(nom::multi::length_data(leb128::nom_leb128_usize), |_| ())(
211
2
                inner_bytes,
212
2
            ),
213
0
            _ => Err(nom::Err::Error(nom::error::ParseError::from_error_kind(
214
0
                bytes,
215
0
                nom::error::ErrorKind::Tag,
216
0
            ))),
217
20
        }
Unexecuted instantiation: _RNCNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00Ba_
Unexecuted instantiation: _RNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE00CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE00Ba_
Unexecuted instantiation: _RNCNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE00CsiUjFBJteJ7x_17smoldot_full_node
218
21
    
}20
)(bytes)
_RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
Line
Count
Source
205
20
    nom::combinator::flat_map(tag_decode, |(_, wire_ty)| {
206
        move |inner_bytes| match wire_ty {
207
            0 => nom::combinator::map(leb128::nom_leb128_u64, |_| ())(inner_bytes),
208
            5 => nom::combinator::map(nom::bytes::streaming::take(4u32), |_| ())(inner_bytes),
209
            1 => nom::combinator::map(nom::bytes::streaming::take(8u32), |_| ())(inner_bytes),
210
            2 => nom::combinator::map(nom::multi::length_data(leb128::nom_leb128_usize), |_| ())(
211
                inner_bytes,
212
            ),
213
            _ => Err(nom::Err::Error(nom::error::ParseError::from_error_kind(
214
                bytes,
215
                nom::error::ErrorKind::Tag,
216
            ))),
217
        }
218
20
    })(bytes)
Unexecuted instantiation: _RNCINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0CsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEE0B8_
Unexecuted instantiation: _RNCINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEE0CsiUjFBJteJ7x_17smoldot_full_node
219
21
}
_RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Line
Count
Source
202
21
pub(crate) fn tag_value_skip_decode<'a, E: nom::error::ParseError<&'a [u8]>>(
203
21
    bytes: &'a [u8],
204
21
) -> nom::IResult<&'a [u8], (), E> {
205
21
    nom::combinator::flat_map(tag_decode, |(_, wire_ty)| {
206
        move |inner_bytes| match wire_ty {
207
            0 => nom::combinator::map(leb128::nom_leb128_u64, |_| ())(inner_bytes),
208
            5 => nom::combinator::map(nom::bytes::streaming::take(4u32), |_| ())(inner_bytes),
209
            1 => nom::combinator::map(nom::bytes::streaming::take(8u32), |_| ())(inner_bytes),
210
            2 => nom::combinator::map(nom::multi::length_data(leb128::nom_leb128_usize), |_| ())(
211
                inner_bytes,
212
            ),
213
            _ => Err(nom::Err::Error(nom::error::ParseError::from_error_kind(
214
                bytes,
215
                nom::error::ErrorKind::Tag,
216
            ))),
217
        }
218
21
    })(bytes)
219
21
}
Unexecuted instantiation: _RINvNtNtCsN16ciHI6Qf_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEECsDDUKWWCHAU_18smoldot_light_wasm
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeINtNtCs6ga8gEqbpRc_3nom5error5ErrorRShEEB6_
Unexecuted instantiation: _RINvNtNtCseuYC0Zibziv_7smoldot4util8protobuf21tag_value_skip_decodeTRShNtNtCs6ga8gEqbpRc_3nom5error9ErrorKindEECsiUjFBJteJ7x_17smoldot_full_node
220
221
/// Decodes a Protobuf message.
222
///
223
/// Importantly, this does **not** expect a Protobuf tag in front of the message. If the message
224
/// is part of another message, you must wrap this macro call around [`message_tag_decode`].
225
///
226
/// This macro expects a list of fields, each field has one of the three following formats:
227
///
228
/// ```ignore
229
/// #[required] field_name = num => parser
230
/// #[optional] field_name = num => parser
231
/// #[repeated(max = expr)] field_name = num => parser
232
/// ```
233
///
234
/// `field_name` must be an identifier, `num` the field number according to the Protobuf
235
/// definition, and `parser` an inner parser that parses a Protobuf tag and value.
236
/// If `#[optional]` is provided, then the value produced by `parser` is wrapped around an
237
/// `Option`, and the decoding of the message will succeed even if the field is missing.
238
/// If `#[repeated(max = n)]` is provided, then the value produced by `parser` is wrapped
239
/// around a `Vec`, and the field can be provided multiple times in the message. No more than
240
/// `n` items can be added to the `Vec` before the decoding fails.
241
/// Note that `num` and `n` (the maximum number of items in a `Vec`) can be expressions.
242
/// It is not possible to pass both `#[optional]` and `#[repeated]` at the same time.
243
///
244
/// The macro produces a `nom` parser that outputs an anonymous struct whose field correspond
245
/// to the provided field names.
246
///
247
/// # About `optional` fields
248
///
249
/// A field can be either "required" (if marked with `#[required]`) or "optional" (if marked
250
/// with `#[optional]` or `#[repeated]`).
251
///
252
/// When translating Protobuf definitions into a decoder using this macro, it can be tricky to
253
/// know whether to mark fields as `#[optional]`. If the definition uses `proto2`, then all fields
254
/// of the definition are always serialized, meaning that they will always be found in the encoded
255
/// message. If the definition uses `proto3`, however, then fields that contain their default value
256
/// (typically `0` or an empty string/bytes) are intentionally omitted unless they are marked as
257
/// `optional`.
258
///
259
/// In general, you probably want to mark as `#[optional]` all the fields where `0` or an empty
260
/// string/bytes is a valid value.
261
///
262
/// See also <https://github.com/protocolbuffers/protobuf/blob/main/docs/field_presence.md>.
263
///
264
/// # Example
265
///
266
/// ```ignore
267
/// let _parser = nom::combinator::all_consuming::<_, _, nom::error::Error<&[u8]>, _>(
268
///     nom::combinator::complete(protobuf::message_decode! {
269
///         #[repeated(max = 4)] entries = 1 => protobuf::message_decode!{
270
///             #[required] state_root = 1 => protobuf::bytes_tag_decode(1),
271
///             #[repeated(max = 10)] entries = 2 => protobuf::message_tag_decode(2, protobuf::message_decode!{
272
///                 #[required] key = 1 => protobuf::bytes_tag_decode(1),
273
///                 #[required] value = 2 => protobuf::bytes_tag_decode(2),
274
///             }),
275
///             #[optional] complete = 3 => protobuf::bool_tag_decode(3),
276
///         }
277
///     }),
278
/// );
279
/// ```
280
///
281
macro_rules! message_decode {
282
    ($($(#[$($attrs:tt)*])* $field_name:ident = $field_num:expr => $parser:expr),*,) => {
283
        $crate::util::protobuf::message_decode!($($(#[$($attrs)*])* $field_name = $field_num => $parser),*)
284
    };
285
    ($($(#[$($attrs:tt)*])* $field_name:ident = $field_num:expr => $parser:expr),*) => {{
286
        #[allow(non_camel_case_types)]
287
        struct Out<$($field_name),*> {
288
            $($field_name: $field_name,)*
289
        }
290
291
        |mut input| {
292
            #[allow(non_camel_case_types)]
293
            struct InProgress<$($field_name),*> {
294
                $($field_name: $crate::util::protobuf::message_decode_helper_ty!($field_name; $($($attrs)*)*),)*
295
            }
296
297
            let mut in_progress = InProgress {
298
                $($field_name: Default::default(),)*
299
            };
300
301
            loop {
302
                // Note: it might be tempting to write `input: &[u8]` as the closure parameter
303
                // instead, but this causes lifetime issues for some reason.
304
                if <[u8]>::is_empty(input) {
305
                    break;
306
                }
307
308
                let (_, (field_num, _wire_ty)) = $crate::util::protobuf::tag_decode(input)?;
309
310
                $(if field_num == $field_num {
311
                    let (rest, value) = nom::Parser::<&[u8], _, _>::parse(&mut $parser, input)?;
312
313
                    if input == rest {
314
                        // The field parser didn't consume any byte. This will lead
315
                        // to an infinite loop. Return an error to prevent this from
316
                        // happening.
317
                        return core::result::Result::Err(nom::Err::Error(
318
                            nom::error::ParseError::<&[u8]>::from_error_kind(rest, nom::error::ErrorKind::Alt)
319
                        ));
320
                    }
321
322
                    $crate::util::protobuf::message_decode_helper_store!(input, value => in_progress.$field_name; $($($attrs)*)*);
323
                    input = rest;
324
                    continue;
325
                })*
326
327
                // Fields with an unrecognized number are deliberately ignored. This is
328
                // a fundamental feature of protobuf in order to make protocol upgrades
329
                // easier.
330
                let (rest, ()) = $crate::util::protobuf::tag_value_skip_decode(input)?;
331
                debug_assert!(input != rest);
332
                input = rest;
333
            }
334
335
            let out = Out {
336
                $($field_name: $crate::util::protobuf::message_decode_helper_unwrap!(in_progress.$field_name; $($($attrs)*)*)?,)*
337
            };
338
339
            Ok((input, out))
340
        }
341
    }};
342
}
343
344
macro_rules! message_decode_helper_ty {
345
    ($ty:ty; required) => { Option<$ty> };
346
    ($ty:ty; optional) => { Option<$ty> };
347
    ($ty:ty; repeated(max = $max:expr)) => { Vec<$ty> };
348
}
349
350
macro_rules! message_decode_helper_store {
351
    ($input_data:expr, $value:expr => $dest:expr; required) => {
352
        if $dest.is_some() {
353
            // Make sure that the field is only found once in the message.
354
            return core::result::Result::Err(nom::Err::Error(
355
                nom::error::ParseError::<&[u8]>::from_error_kind(
356
                    $input_data,
357
                    nom::error::ErrorKind::Many1,
358
                ),
359
            ));
360
        }
361
        $dest = Some($value);
362
    };
363
    ($input_data:expr, $value:expr => $dest:expr; optional) => {
364
        if $dest.is_some() {
365
            // Make sure that the field is only found once in the message.
366
            return core::result::Result::Err(nom::Err::Error(
367
                nom::error::ParseError::<&[u8]>::from_error_kind(
368
                    $input_data,
369
                    nom::error::ErrorKind::Many1,
370
                ),
371
            ));
372
        }
373
        $dest = Some($value);
374
    };
375
    ($input_data:expr, $value:expr => $dest:expr; repeated(max = $max:expr)) => {
376
        if $dest.len() >= usize::try_from($max).unwrap_or(usize::MAX) {
377
            return core::result::Result::Err(nom::Err::Error(
378
                nom::error::ParseError::<&[u8]>::from_error_kind(
379
                    $input_data,
380
                    nom::error::ErrorKind::Many1,
381
                ),
382
            ));
383
        }
384
        $dest.push($value);
385
    };
386
}
387
388
macro_rules! message_decode_helper_unwrap {
389
    ($value:expr; required) => {
390
        $value.ok_or_else(|| {
391
            nom::Err::Error(nom::error::ParseError::<&[u8]>::from_error_kind(
392
                &[][..],
393
                nom::error::ErrorKind::NoneOf,
394
            ))
395
        })
396
    };
397
    ($value:expr; optional) => {
398
        Ok($value)
399
    };
400
    ($value:expr; repeated(max = $max:expr)) => {
401
        Ok($value)
402
    };
403
}
404
405
pub(crate) use {
406
    message_decode, message_decode_helper_store, message_decode_helper_ty,
407
    message_decode_helper_unwrap,
408
};
409
410
#[cfg(test)]
411
mod tests {
412
    #[test]
413
1
    fn encode_decode_bool() {
414
3
        let encoded = super::bool_tag_encode(504, true).fold(Vec::new(), |mut a, b| {
415
3
            a.extend_from_slice(b.as_ref());
416
3
            a
417
3
        });
418
1
419
1
        assert_eq!(&encoded, &[192, 31, 1]);
420
421
1
        let decoded = super::bool_tag_decode::<nom::error::Error<&[u8]>>(&encoded)
422
1
            .unwrap()
423
1
            .1;
424
1
        assert!(decoded);
425
1
    }
426
427
    #[test]
428
1
    fn encode_decode_uint32() {
429
6
        let encoded = super::uint32_tag_encode(8670, 93701).fold(Vec::new(), |mut a, b| {
430
6
            a.extend_from_slice(b.as_ref());
431
6
            a
432
6
        });
433
1
434
1
        assert_eq!(&encoded, &[240, 157, 4, 133, 220, 5]);
435
436
1
        let decoded = super::uint32_tag_decode::<nom::error::Error<&[u8]>>(&encoded)
437
1
            .unwrap()
438
1
            .1;
439
1
        assert_eq!(decoded, 93701);
440
1
    }
441
442
    #[test]
443
1
    fn encode_decode_enum() {
444
5
        let encoded = super::enum_tag_encode(107, 935237).fold(Vec::new(), |mut a, b| {
445
5
            a.extend_from_slice(b.as_ref());
446
5
            a
447
5
        });
448
1
449
1
        assert_eq!(&encoded, &[216, 6, 197, 138, 57]);
450
451
1
        let decoded = super::enum_tag_decode::<nom::error::Error<&[u8]>>(&encoded)
452
1
            .unwrap()
453
1
            .1;
454
1
        assert_eq!(decoded, 935237);
455
1
    }
456
457
    #[test]
458
1
    fn encode_decode_string() {
459
4
        let encoded = super::string_tag_encode(490, "hello world").fold(Vec::new(), |mut a, b| {
460
4
            a.extend_from_slice(b.as_ref());
461
4
            a
462
4
        });
463
1
464
1
        assert_eq!(
465
1
            &encoded,
466
1
            &[210, 30, 11, 104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
467
1
        );
468
469
1
        let decoded = super::string_tag_decode::<nom::error::Error<&[u8]>>(&encoded)
470
1
            .unwrap()
471
1
            .1;
472
1
        assert_eq!(decoded, "hello world");
473
1
    }
474
475
    #[test]
476
1
    fn encode_decode_bytes() {
477
3
        let encoded = super::bytes_tag_encode(2, b"test").fold(Vec::new(), |mut a, b| {
478
3
            a.extend_from_slice(b.as_ref());
479
3
            a
480
3
        });
481
1
482
1
        assert_eq!(&encoded, &[18, 4, 116, 101, 115, 116]);
483
484
1
        let decoded = super::bytes_tag_decode::<nom::error::Error<&[u8]>>(&encoded)
485
1
            .unwrap()
486
1
            .1;
487
1
        assert_eq!(decoded, b"test");
488
1
    }
489
490
    #[test]
491
1
    fn large_values_dont_crash() {
492
1
        // Payload starts with a LEB128 that corresponds to a very very large field identifier.
493
256
        let encoded = (0..256).map(|_| 129).collect::<Vec<_>>();
494
1
        assert!(super::tag_value_skip_decode::<nom::error::Error<&[u8]>>(&encoded).is_err());
495
1
    }
496
}