Use strings for paths and buffer contents

Max Brunsfeld created

Change summary

zed-rpc/proto/zed.proto |  8 ++++----
zed-rpc/src/peer.rs     | 16 ++++++++--------
zed-rpc/src/proto.rs    |  2 +-
zed/src/worktree.rs     |  2 +-
4 files changed, 14 insertions(+), 14 deletions(-)

Detailed changes

zed-rpc/proto/zed.proto 🔗

@@ -45,7 +45,7 @@ message OpenWorktreeResponse {
 
 message OpenBuffer {
     uint64 worktree_id = 1;
-    bytes path = 2;
+    string path = 2;
 }
 
 message OpenBufferResponse {
@@ -53,13 +53,13 @@ message OpenBufferResponse {
 }
 
 message Worktree {
-    repeated bytes paths = 1;
+    repeated string paths = 1;
 }
 
 message Buffer {
     uint64 id = 1;
-    bytes path = 2;
-    bytes content = 3;
+    string path = 2;
+    string content = 3;
     repeated Operation history = 4;
 }
 

zed-rpc/src/peer.rs 🔗

@@ -340,7 +340,7 @@ mod tests {
             };
             let response1 = proto::OpenWorktreeResponse {
                 worktree: Some(proto::Worktree {
-                    paths: vec![b"path/one".to_vec()],
+                    paths: vec!["path/one".to_string()],
                 }),
             };
             let request2 = proto::OpenWorktree {
@@ -349,30 +349,30 @@ mod tests {
             };
             let response2 = proto::OpenWorktreeResponse {
                 worktree: Some(proto::Worktree {
-                    paths: vec![b"path/two".to_vec(), b"path/three".to_vec()],
+                    paths: vec!["path/two".to_string(), "path/three".to_string()],
                 }),
             };
             let request3 = proto::OpenBuffer {
                 worktree_id: 102,
-                path: b"path/two".to_vec(),
+                path: "path/two".to_string(),
             };
             let response3 = proto::OpenBufferResponse {
                 buffer: Some(proto::Buffer {
                     id: 1001,
-                    path: b"path/two".to_vec(),
-                    content: b"path/two content".to_vec(),
+                    path: "path/two".to_string(),
+                    content: "path/two content".to_string(),
                     history: vec![],
                 }),
             };
             let request4 = proto::OpenBuffer {
                 worktree_id: 101,
-                path: b"path/one".to_vec(),
+                path: "path/one".to_string(),
             };
             let response4 = proto::OpenBufferResponse {
                 buffer: Some(proto::Buffer {
                     id: 1002,
-                    path: b"path/one".to_vec(),
-                    content: b"path/one content".to_vec(),
+                    path: "path/one".to_string(),
+                    content: "path/one content".to_string(),
                     history: vec![],
                 }),
             };

zed-rpc/src/proto.rs 🔗

@@ -131,7 +131,7 @@ mod tests {
 
             let message2 = ShareWorktree {
                 worktree: Some(Worktree {
-                    paths: vec![b"ok".to_vec()],
+                    paths: vec!["ok".to_string()],
                 }),
             }
             .into_envelope(5, None);

zed/src/worktree.rs 🔗

@@ -239,7 +239,7 @@ impl Worktree {
                 .spawn(async move {
                     snapshot
                         .paths()
-                        .map(|path| path.as_os_str().as_bytes().to_vec())
+                        .map(|path| path.to_string_lossy().to_string())
                         .collect()
                 })
                 .await;