Skip to content

Commit

Permalink
serialize: make Paths serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Mar 13, 2014
1 parent be12c9f commit d2cfd54
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/libserialize/serialize.rs
Expand Up @@ -14,6 +14,7 @@
Core encoding and decoding interfaces.
*/

use std::path;
use std::rc::Rc;
use std::vec;
use std::vec_ng::Vec;
Expand Down Expand Up @@ -625,6 +626,32 @@ impl<
}
}

impl<E: Encoder> Encodable<E> for path::posix::Path {
fn encode(&self, e: &mut E) {
self.as_vec().encode(e)
}
}

impl<D: Decoder> Decodable<D> for path::posix::Path {
fn decode(d: &mut D) -> path::posix::Path {
let bytes: ~[u8] = Decodable::decode(d);
path::posix::Path::new(bytes)
}
}

impl<E: Encoder> Encodable<E> for path::windows::Path {
fn encode(&self, e: &mut E) {
self.as_vec().encode(e)
}
}

impl<D: Decoder> Decodable<D> for path::windows::Path {
fn decode(d: &mut D) -> path::windows::Path {
let bytes: ~[u8] = Decodable::decode(d);
path::windows::Path::new(bytes)
}
}

// ___________________________________________________________________________
// Helper routines
//
Expand Down

0 comments on commit d2cfd54

Please sign in to comment.