Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Chiguireitor
addrindexrs
Commits
1786fa69
Unverified
Commit
1786fa69
authored
May 26, 2018
by
Roman Zeyde
Browse files
Refactor Connection::send_value()
parent
ae438b55
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
src/rpc.rs
src/rpc.rs
+13
-12
No files found.
src/rpc.rs
View file @
1786fa69
...
...
@@ -239,12 +239,15 @@ impl Connection {
Ok
(
result
)
}
fn
send_value
(
&
mut
self
,
v
:
Value
)
->
Result
<
()
>
{
debug!
(
"[{}] <- {}"
,
self
.addr
,
v
);
let
line
=
v
.to_string
()
+
"
\n
"
;
self
.stream
.write_all
(
line
.as_bytes
())
.chain_err
(||
format!
(
"failed to send {}"
,
v
))
fn
send_values
(
&
mut
self
,
values
:
&
[
Value
])
->
Result
<
()
>
{
for
value
in
values
{
debug!
(
"[{}] <- {}"
,
self
.addr
,
value
);
let
line
=
value
.to_string
()
+
"
\n
"
;
self
.stream
.write_all
(
line
.as_bytes
())
.chain_err
(||
format!
(
"failed to send {}"
,
value
))
?
;
}
Ok
(())
}
fn
handle_replies
(
&
mut
self
,
chan
:
&
Channel
)
->
Result
<
()
>
{
...
...
@@ -268,14 +271,12 @@ impl Connection {
)
=>
self
.handle_command
(
method
,
params
,
id
)
?
,
_
=>
bail!
(
"invalid command: {}"
,
cmd
),
};
self
.send_value
(
reply
)
?
self
.send_value
s
(
&
[
reply
]
)
?
}
Message
::
PeriodicUpdate
=>
{
for
update
in
self
.update_subscriptions
()
.chain_err
(||
"failed to update subscriptions"
)
?
{
self
.send_value
(
update
)
?
}
let
values
=
self
.update_subscriptions
()
.chain_err
(||
"failed to update subscriptions"
)
?
;
self
.send_values
(
&
values
)
?
}
Message
::
Done
=>
{
debug!
(
"done"
);
...
...
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