Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
shasper
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
shasper
Commits
1867f131
Commit
1867f131
authored
5 years ago
by
Wei Tang
Browse files
Options
Downloads
Patches
Plain Diff
beacon: refactor serde utils to its own mod
Saves a lot of cfg macro
parent
3507c389
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beacon/src/utils/mod.rs
+5
-0
5 additions, 0 deletions
beacon/src/utils/mod.rs
beacon/src/utils/serde.rs
+0
-8
0 additions, 8 deletions
beacon/src/utils/serde.rs
with
5 additions
and
8 deletions
beacon/src/utils/mod.rs
0 → 100644
+
5
−
0
View file @
1867f131
#[cfg(feature
=
"serde"
)]
mod
serde
;
#[cfg(feature
=
"serde"
)]
pub
use
self
::
serde
::
*
;
This diff is collapsed.
Click to expand it.
beacon/src/utils.rs
→
beacon/src/utils
/serde
.rs
+
0
−
8
View file @
1867f131
#[cfg(feature
=
"serde"
)]
use
serde
::{
Serializer
,
Deserializer
,
de
::
Error
as
_
};
#[cfg(feature
=
"serde"
)]
use
impl_serde
::
serialize
;
use
core
::
convert
::
TryFrom
;
#[cfg(feature
=
"serde"
)]
pub
fn
serialize_bitseq
<
T
:
AsRef
<
[
bool
]
>
,
S
:
Serializer
>
(
value
:
&
T
,
serializer
:
S
,
...
...
@@ -23,19 +20,16 @@ pub fn serialize_bitseq<T: AsRef<[bool]>, S: Serializer>(
serialize
::
serialize
(
&
bytes
,
serializer
)
}
#[cfg(feature
=
"serde"
)]
pub
fn
serialize_bitlist
<
ML
,
S
:
Serializer
>
(
value
:
&
bm_le
::
MaxVec
<
bool
,
ML
>
,
serializer
:
S
)
->
Result
<
S
::
Ok
,
S
::
Error
>
{
serialize_bitseq
(
value
,
serializer
,
true
)
}
#[cfg(feature
=
"serde"
)]
pub
fn
serialize_bitvector
<
L
:
typenum
::
Unsigned
,
S
:
Serializer
>
(
value
:
&
vecarray
::
VecArray
<
bool
,
L
>
,
serializer
:
S
)
->
Result
<
S
::
Ok
,
S
::
Error
>
{
serialize_bitseq
(
value
,
serializer
,
false
)
}
#[cfg(feature
=
"serde"
)]
pub
fn
deserialize_bitseq
<
'a
,
'de
,
D
:
Deserializer
<
'de
>>
(
deserializer
:
D
,
is_list
:
bool
,
...
...
@@ -51,14 +45,12 @@ pub fn deserialize_bitseq<'a, 'de, D: Deserializer<'de>>(
Ok
(
ret
)
}
#[cfg(feature
=
"serde"
)]
pub
fn
deserialize_bitlist
<
'a
,
'de
,
ML
,
D
:
Deserializer
<
'de
>>
(
deserializer
:
D
)
->
Result
<
bm_le
::
MaxVec
<
bool
,
ML
>
,
D
::
Error
>
{
Ok
(
bm_le
::
MaxVec
::
from
(
deserialize_bitseq
(
deserializer
,
true
)
?
))
}
#[cfg(feature
=
"serde"
)]
pub
fn
deserialize_bitvector
<
'a
,
'de
,
L
:
typenum
::
Unsigned
,
D
:
Deserializer
<
'de
>>
(
deserializer
:
D
)
->
Result
<
vecarray
::
VecArray
<
bool
,
L
>
,
D
::
Error
>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment