Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
ink
Commits
97696ec1
Commit
97696ec1
authored
Jan 23, 2019
by
Hero Bird
Browse files
[pdsl_core] Implement Flush for storage::{Value, Vec, HashMap, Stash}
parent
577e9645
Changes
5
Hide whitespace changes
Inline
Side-by-side
pdsl_core/src/storage/cell/sync_cell.rs
View file @
97696ec1
...
...
@@ -332,7 +332,7 @@ impl<T> parity_codec::Decode for SyncCell<T> {
impl
<
T
>
Flush
for
SyncCell
<
T
>
where
T
:
parity_codec
::
C
ode
c
,
T
:
parity_codec
::
Enc
ode
,
{
fn
flush
(
&
mut
self
)
{
if
self
.cache
.is_dirty
()
{
...
...
pdsl_core/src/storage/collections/hash_map/hash_map.rs
View file @
97696ec1
...
...
@@ -19,6 +19,7 @@ use crate::storage::{
chunk
::
SyncChunk
,
Setup
,
Allocator
,
Flush
,
};
use
crate
::
hash
;
...
...
@@ -85,6 +86,17 @@ impl<K, V> Setup for HashMap<K, V> {
}
}
impl
<
K
,
V
>
Flush
for
HashMap
<
K
,
V
>
where
K
:
parity_codec
::
Encode
,
V
:
parity_codec
::
Encode
,
{
fn
flush
(
&
mut
self
)
{
self
.len
.flush
();
self
.entries
.flush
();
}
}
impl
<
K
,
V
>
parity_codec
::
Encode
for
HashMap
<
K
,
V
>
{
fn
encode_to
<
W
:
parity_codec
::
Output
>
(
&
self
,
dest
:
&
mut
W
)
{
self
.len
.encode_to
(
dest
);
...
...
pdsl_core/src/storage/collections/stash/stash.rs
View file @
97696ec1
...
...
@@ -19,6 +19,7 @@ use crate::storage::{
Key
,
chunk
::
SyncChunk
,
Allocator
,
Flush
,
};
use
parity_codec
::{
Encode
,
Decode
};
...
...
@@ -74,6 +75,18 @@ impl<'a, T> Values<'a, T> {
}
}
impl
<
T
>
Flush
for
Stash
<
T
>
where
T
:
parity_codec
::
Encode
,
{
fn
flush
(
&
mut
self
)
{
self
.next_vacant
.flush
();
self
.len
.flush
();
self
.max_len
.flush
();
self
.entries
.flush
();
}
}
impl
<
'a
,
T
>
Iterator
for
Values
<
'a
,
T
>
where
T
:
parity_codec
::
Codec
...
...
pdsl_core/src/storage/collections/vec/vec.rs
View file @
97696ec1
...
...
@@ -19,6 +19,7 @@ use crate::{
self
,
chunk
::
SyncChunk
,
Allocator
,
Flush
,
},
};
...
...
@@ -71,6 +72,16 @@ impl<'a, T> Iter<'a, T> {
}
}
impl
<
T
>
Flush
for
Vec
<
T
>
where
T
:
parity_codec
::
Encode
,
{
fn
flush
(
&
mut
self
)
{
self
.len
.flush
();
self
.cells
.flush
();
}
}
impl
<
'a
,
T
>
Iterator
for
Iter
<
'a
,
T
>
where
T
:
parity_codec
::
Codec
...
...
pdsl_core/src/storage/value.rs
View file @
97696ec1
...
...
@@ -138,7 +138,7 @@ where
impl
<
T
>
Flush
for
Value
<
T
>
where
T
:
parity_codec
::
C
ode
c
+
Unpin
,
T
:
parity_codec
::
Enc
ode
+
Unpin
,
{
fn
flush
(
&
mut
self
)
{
self
.cell
.flush
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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