Skip to content

Commit d2cfd54

Browse files
committed
serialize: make Paths serializable
1 parent be12c9f commit d2cfd54

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/libserialize/serialize.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Core encoding and decoding interfaces.
1515
*/
1616

17+
use std::path;
1718
use std::rc::Rc;
1819
use std::vec;
1920
use std::vec_ng::Vec;
@@ -625,6 +626,32 @@ impl<
625626
}
626627
}
627628

629+
impl<E: Encoder> Encodable<E> for path::posix::Path {
630+
fn encode(&self, e: &mut E) {
631+
self.as_vec().encode(e)
632+
}
633+
}
634+
635+
impl<D: Decoder> Decodable<D> for path::posix::Path {
636+
fn decode(d: &mut D) -> path::posix::Path {
637+
let bytes: ~[u8] = Decodable::decode(d);
638+
path::posix::Path::new(bytes)
639+
}
640+
}
641+
642+
impl<E: Encoder> Encodable<E> for path::windows::Path {
643+
fn encode(&self, e: &mut E) {
644+
self.as_vec().encode(e)
645+
}
646+
}
647+
648+
impl<D: Decoder> Decodable<D> for path::windows::Path {
649+
fn decode(d: &mut D) -> path::windows::Path {
650+
let bytes: ~[u8] = Decodable::decode(d);
651+
path::windows::Path::new(bytes)
652+
}
653+
}
654+
628655
// ___________________________________________________________________________
629656
// Helper routines
630657
//

0 commit comments

Comments
 (0)