(path: &str, json: &S)
| 16 | } |
| 17 | |
| 18 | pub async fn to_json_file<S>(path: &str, json: &S) -> Result<()> |
| 19 | where |
| 20 | S: serde::Serialize, |
| 21 | { |
| 22 | let mut file_sink = create_file_sink(path) |
| 23 | .await |
| 24 | .context("Fail to create file sink")?; |
| 25 | serde_json::to_writer_pretty(file_sink.as_writer(), json).context("Fail to write JSON")?; |
| 26 | file_sink.flush(1).await.context("Fail to flush")?; |
| 27 | Ok(()) |
| 28 | } |
| 29 | |
| 30 | async fn create_file_sink<T>(path: T) -> Result<sea_streamer_file::FileSink> |
| 31 | where |