Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
parity-scale-codec
Commits
7ff1b558
Commit
7ff1b558
authored
Jun 21, 2019
by
Kian Peymani
Committed by
Bastian Köcher
Jun 21, 2019
Browse files
fix function api for len. (#103)
parent
7a972929
Pipeline
#40992
passed with stages
in 14 minutes and 4 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/codec.rs
View file @
7ff1b558
...
...
@@ -229,7 +229,7 @@ pub trait EncodeAppend {
/// to read and decode the entire elements.
pub
trait
DecodeLength
{
/// Return the number of elements in `self_encoded`.
fn
len
(
self_encoded
:
&
mut
&
[
u8
])
->
Result
<
usize
,
Error
>
;
fn
len
(
self_encoded
:
&
[
u8
])
->
Result
<
usize
,
Error
>
;
}
/// Trait that allows zero-copy read of value-references from slices in LE format.
...
...
@@ -689,8 +689,8 @@ impl Decode for () {
macro_rules!
impl_len
{
(
$
(
$type:ident
<
$
(
$g:ident
),
*
>
),
*
)
=>
{
$
(
impl
<
$
(
$g
),
*>
DecodeLength
for
$type
<
$
(
$g
),
*>
{
fn
len
(
self_encoded
:
&
mut
&
[
u8
])
->
Result
<
usize
,
Error
>
{
usize
::
try_from
(
u32
::
from
(
Compact
::
<
u32
>
::
decode
(
self_encoded
)
?
))
fn
len
(
mut
self_encoded
:
&
[
u8
])
->
Result
<
usize
,
Error
>
{
usize
::
try_from
(
u32
::
from
(
Compact
::
<
u32
>
::
decode
(
&
mut
self_encoded
)
?
))
.map_err
(|
_
|
"Failed convert decded size into usize."
.into
())
}
}
...
...
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment