pub struct MountPathCodec { /* private fields */ }Expand description
Prefix-mapping codec: readable shadow namespaces backed by real subtrees.
Each entry maps a shadow prefix to a real prefix (canonical relative
form, no leading/trailing /, root is ""):
use libfw_core::pathmap::{MountPathCodec, PathCodec};
let codec = MountPathCodec::new(vec![
("home/alice".to_string(), "data/vol-3/alice".to_string()),
]);
// real → shadow: the real subtree is aliased under the shadow prefix
assert_eq!(
codec.encode("data/vol-3/alice/report.pdf"),
"home/alice/report.pdf"
);
// shadow → real
assert_eq!(
codec.decode("home/alice/report.pdf").unwrap(),
"data/vol-3/alice/report.pdf"
);
// a shadow outside every mapping is rejected …
assert!(codec.decode("other/thing.txt").is_err());
// … while a real path outside every mapping passes through unchanged
assert_eq!(codec.encode("public/readme.md"), "public/readme.md");Matching is on segment boundaries: home/alice matches home/alice/x
but not home/alice2/x. When several entries match, the longest shadow
prefix wins (most specific mapping).
Implementations§
Trait Implementations§
Source§impl Clone for MountPathCodec
impl Clone for MountPathCodec
Source§impl Debug for MountPathCodec
impl Debug for MountPathCodec
Source§impl Default for MountPathCodec
impl Default for MountPathCodec
Auto Trait Implementations§
impl Freeze for MountPathCodec
impl RefUnwindSafe for MountPathCodec
impl Send for MountPathCodec
impl Sync for MountPathCodec
impl Unpin for MountPathCodec
impl UnsafeUnpin for MountPathCodec
impl UnwindSafe for MountPathCodec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more