Method
write
(self, w: &mut impl io::Write)
Source from the content-addressed store, hash-verified
| 114 | } |
| 115 | |
| 116 | pub fn write(self, w: &mut impl io::Write) -> io::Result<()> { |
| 117 | #[derive(Serialize)] |
| 118 | struct JSONRPCMessage { |
| 119 | jsonrpc: &'static str, |
| 120 | #[serde(flatten)] |
| 121 | message: Message, |
| 122 | } |
| 123 | let msg = to_string(&JSONRPCMessage { jsonrpc: "2.0", message: self })?; |
| 124 | write!(w, "Content-Length: {}\r\n\r\n", msg.len())?; |
| 125 | w.write_all(msg.as_bytes())?; |
| 126 | w.flush()?; |
| 127 | Ok(()) |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | #[derive(Debug)] |