-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring back some notion of vendored-stub-file "metadata"
- Loading branch information
1 parent
df248ce
commit 96159d9
Showing
5 changed files
with
108 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/// A number representing the revision of a file. | ||
/// | ||
/// Two revisions that don't compare equal signify that the file has been modified. | ||
/// Revisions aren't guaranteed to be monotonically increasing or in any specific order. | ||
/// | ||
/// Possible revisions are: | ||
/// * The last modification time of the file. | ||
/// * The hash of the file's content. | ||
/// * The revision as it comes from an external system, for example the LSP. | ||
#[derive(Copy, Clone, Debug, Eq, PartialEq)] | ||
pub struct FileRevision(u128); | ||
|
||
impl FileRevision { | ||
pub fn new(value: u128) -> Self { | ||
Self(value) | ||
} | ||
|
||
pub const fn zero() -> Self { | ||
Self(0) | ||
} | ||
|
||
#[must_use] | ||
pub fn as_u128(self) -> u128 { | ||
self.0 | ||
} | ||
} | ||
|
||
impl From<u128> for FileRevision { | ||
fn from(value: u128) -> Self { | ||
FileRevision(value) | ||
} | ||
} | ||
|
||
impl From<u64> for FileRevision { | ||
fn from(value: u64) -> Self { | ||
FileRevision(u128::from(value)) | ||
} | ||
} | ||
|
||
impl From<filetime::FileTime> for FileRevision { | ||
fn from(value: filetime::FileTime) -> Self { | ||
let seconds = value.seconds() as u128; | ||
let seconds = seconds << 64; | ||
let nanos = u128::from(value.nanoseconds()); | ||
|
||
FileRevision(seconds | nanos) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters