Emit a diff event when worktree's snapshot is updated

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld
2021-06-21 17:07:56 -07:00
co-authored by Nathan Sobo
parent 8ae5c0d7d6
commit cabf6b1f58
4 changed files with 186 additions and 71 deletions
+23 -1
View File
@@ -1,6 +1,10 @@
use futures::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt as _};
use prost::Message;
use std::{convert::TryInto, io};
use std::{
convert::TryInto,
io,
time::{Duration, SystemTime, UNIX_EPOCH},
};
include!(concat!(env!("OUT_DIR"), "/zed.messages.rs"));
@@ -122,6 +126,24 @@ where
}
}
impl Into<SystemTime> for Timestamp {
fn into(self) -> SystemTime {
UNIX_EPOCH
.checked_add(Duration::new(self.seconds, self.nanos))
.unwrap()
}
}
impl From<SystemTime> for Timestamp {
fn from(time: SystemTime) -> Self {
let duration = time.duration_since(UNIX_EPOCH).unwrap();
Self {
seconds: duration.as_secs(),
nanos: duration.subsec_nanos(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;