1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use std::ffi::{OsStr, OsString};
use serde::{Deserialize, Serialize};
use crate::{FileId, PeerId};
/// TODO: docs
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct FileMoved {
id: FileId,
moved_by: PeerId,
new_name: Option<OsString>,
new_parent: Option<FileId>,
}
impl FileMoved {
/// Returns the [`FileId`] of the file that was moved.
#[inline(always)]
pub fn file_id(&self) -> FileId {
self.id
}
/// Returns the [`PeerId`] of the peer that moved the file.
#[inline(always)]
pub fn moved_by(&self) -> PeerId {
self.moved_by
}
/// Returns the file's new name if it was renamed, or `None` otherwise.
#[inline(always)]
pub fn new_name(&self) -> Option<&OsStr> {
self.new_name.as_deref()
}
/// Returns the [`FileId`] of the new parent if the file was moved under
/// a different [`Directory`](crate::Directory), or `None` if it stayed
/// under the same one.
#[inline(always)]
pub fn new_parent(&self) -> Option<FileId> {
self.new_parent
}
}