Debian Codegraph @

src/modify.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::{CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#, CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#};
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#;
4
5 use nixrust-analyzer cargo nix 0.31.3 crate/::mountrust-analyzer cargo nix 0.31.3 mount/::{MsFlagsrust-analyzer cargo nix 0.31.3 mount/linux/MsFlags#, mountrust-analyzer cargo nix 0.31.3 mount/linux/mount().};
6
7 use {OSErrorrust-analyzer cargo libmount 0.1.15 OSError#, Errorrust-analyzer cargo libmount 0.1.15 Error#};
8 use util::{path_to_cstring, as_path};
9 use explain::{Explainable, exists};
10
11 /// A move operation definition
12 ///
13 /// This is a similar to `mount --move` and allows to atomically move mount
14 /// point from one place to another
15 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
16 pub struct Moverust-analyzer cargo libmount 0.1.15 modify/Move# {
17 sourcerust-analyzer cargo libmount 0.1.15 modify/Move#source.: CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#,
18 targetrust-analyzer cargo libmount 0.1.15 modify/Move#target.: CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#,
19 }
20
21 impl Moverust-analyzer cargo libmount 0.1.15 modify/Move# {
22 /// Create a new Move operation
23 pub fn newrust-analyzer cargo libmount 0.1.15 modify/impl#[Move]new().<A: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>, B: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>>(source: A, target: B) -> Moverust-analyzer cargo libmount 0.1.15 modify/Move# {
24 Moverust-analyzer cargo libmount 0.1.15 modify/Move# {
25 sourcerust-analyzer cargo libmount 0.1.15 modify/Move#source.: path_to_cstringrust-analyzer cargo libmount 0.1.15 util/path_to_cstring().(source.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().()),
26 targetrust-analyzer cargo libmount 0.1.15 modify/Move#target.: path_to_cstringrust-analyzer cargo libmount 0.1.15 util/path_to_cstring().(target.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().()),
27 }
28 }
29
30 /// Execute a move-mountpoint operation
31 pub fn bare_move_mountpointrust-analyzer cargo libmount 0.1.15 modify/impl#[Move]bare_move_mountpoint().(self)
32 -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), OSErrorrust-analyzer cargo libmount 0.1.15 OSError#>
33 {
34 mountrust-analyzer cargo nix 0.31.3 mount/linux/mount().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString][Deref]deref().self.sourcerust-analyzer cargo libmount 0.1.15 modify/Move#source.), &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString][Deref]deref().self.targetrust-analyzer cargo libmount 0.1.15 modify/Move#target., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#::<&CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#>, MsFlagsrust-analyzer cargo nix 0.31.3 mount/linux/MsFlags#::MS_MOVErust-analyzer cargo nix 0.31.3 mount/linux/impl#[MsFlags]MS_MOVE., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#::<&CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#>)
35 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|err| OSErrorrust-analyzer cargo libmount 0.1.15 OSError#::from_nixrust-analyzer cargo libmount 0.1.15 impl#[OSError]from_nix().(err, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(self)))
36 }
37
38 /// Execute a move mountpoint operation and explain the error immediately
39 pub fn move_mountpointrust-analyzer cargo libmount 0.1.15 modify/impl#[Move]move_mountpoint().(self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo libmount 0.1.15 Error#> {
40 self.bare_move_mountpointrust-analyzer cargo libmount 0.1.15 modify/impl#[Move]bare_move_mountpoint().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(OSErrorrust-analyzer cargo libmount 0.1.15 OSError#::explainrust-analyzer cargo libmount 0.1.15 error/impl#[OSError]explain().)
41 }
42 }
43
44 impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Moverust-analyzer cargo libmount 0.1.15 modify/Move# {
45 fn fmtrust-analyzer cargo libmount 0.1.15 modify/impl#[Move][Display]fmt().(&self, fmt: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
46 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(fmt, "move {:?} -> {:?}",
47 as_pathrust-analyzer cargo libmount 0.1.15 util/as_path().(&self.sourcerust-analyzer cargo libmount 0.1.15 modify/Move#source.), as_pathrust-analyzer cargo libmount 0.1.15 util/as_path().(&self.targetrust-analyzer cargo libmount 0.1.15 modify/Move#target.))
48 }
49 }
50
51 impl Explainablerust-analyzer cargo libmount 0.1.15 explain/Explainable# for Moverust-analyzer cargo libmount 0.1.15 modify/Move# {
52 fn explainrust-analyzer cargo libmount 0.1.15 modify/impl#[Move][Explainable]explain().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
53 [
54 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("source: {}", existsrust-analyzer cargo libmount 0.1.15 explain/exists().(as_pathrust-analyzer cargo libmount 0.1.15 util/as_path().(&self.sourcerust-analyzer cargo libmount 0.1.15 modify/Move#source.))),
55 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("target: {}", existsrust-analyzer cargo libmount 0.1.15 explain/exists().(as_pathrust-analyzer cargo libmount 0.1.15 util/as_path().(&self.targetrust-analyzer cargo libmount 0.1.15 modify/Move#target.))),
56 ].joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().(", ")
57 }
58 }
59