From e5a40e09e033fb2e8e5c0aacd418e724e5a87490 Mon Sep 17 00:00:00 2001 From: chrysn Date: Mon, 4 Dec 2017 11:04:56 +0100 Subject: [PATCH] unimplemented encode/decode implementations for wasm and other unknowns The cfg() guards around the encode/decode implementations result in the crate being unusable on wasm32-unknown-unknown or any non-unix non-windows non-redox target. These lines mark the functionality as unimplemented on those platforms (which is a sane behavior for platforms like wasm or bare-metal microprocessors given those have no file system), which makes the crate as a whole usable again for file system unrelated tasks like encoding using the "cbor" crate. --- src/serialize.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/serialize.rs b/src/serialize.rs index 296f3d4..2d565ea 100644 --- a/src/serialize.rs +++ b/src/serialize.rs @@ -1371,6 +1371,10 @@ impl Encodable for path::Path { let v = self.as_os_str().encode_wide().collect::>(); v.encode(e) } + #[cfg(not(any(target_os = "redox", unix, windows)))] + fn encode(&self, _e: &mut S) -> Result<(), S::Error> { + unimplemented!(); + } } impl Encodable for path::PathBuf { @@ -1406,6 +1410,10 @@ impl Decodable for path::PathBuf { p.push(s); Ok(p) } + #[cfg(not(any(target_os = "redox", unix, windows)))] + fn decode(_d: &mut D) -> Result { + unimplemented!(); + } } impl Encodable for Cell {