summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2023-07-06 12:31:00 +0200
committerJustus Winter <justus@sequoia-pgp.org>2023-07-06 19:33:07 +0200
commitf5343076ab1cee2087fb24f96b96cdb5a4092dc5 (patch)
treeb2a400b62589a6a20810fe3b5d3df10bbc2ab563
parentbc7214228a10b613057a8c319534d2fd4560175f (diff)
ipc: Add additional constructors.
-rw-r--r--ipc/src/sexp.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/ipc/src/sexp.rs b/ipc/src/sexp.rs
index 7a8ce18c..69c9e151 100644
--- a/ipc/src/sexp.rs
+++ b/ipc/src/sexp.rs
@@ -414,12 +414,24 @@ impl Drop for String_ {
}
}
+impl From<std::string::String> for String_ {
+ fn from(b: std::string::String) -> Self {
+ Self::new(b.into_bytes())
+ }
+}
+
impl From<&str> for String_ {
fn from(b: &str) -> Self {
Self::new(b.as_bytes().to_vec())
}
}
+impl From<Vec<u8>> for String_ {
+ fn from(b: Vec<u8>) -> Self {
+ Self::new(b.into_boxed_slice())
+ }
+}
+
impl From<&[u8]> for String_ {
fn from(b: &[u8]) -> Self {
Self::new(b.to_vec())