Struct std::fs::FileTimes
文件上各种时间戳的表示
1.Implementations
impl FileTimes
new()
创建一个没有设置时间的新 FileTimes。
rust
pub fn new() -> Self返回值:返回一个新的FileTimes
rust
use std::fs::FileTimes;
fn main() {
let t = FileTimes::new();
println!("{:#?}", t);
/*
FileTimes(
FileTimes {
accessed: None,
modified: None,
created: None,
},
)
*/
}set_accessed()
设置文件的最后访问时间。
rust
pub fn set_accessed(self, t: SystemTime) -> Self参数:
- t:系统时钟的度量SystemTime
返回值:返回自身
rust
use std::fs::FileTimes;
use std::time::SystemTime;
fn main() {
let t = FileTimes::new();
t.set_accessed(SystemTime::now());
println!("{:#?}", t);
}set_modified()
设置文件的最后修改时间。
rust
pub fn set_accessed(self, t: SystemTime) -> Self参数:
- t:系统时钟的度量SystemTime
返回值:返回自身
2.Trait Implementations
impl Clone for FileTimes
clone
返回值的副本。
rust
fn clone(&self) -> FileTimesclone_from
把另一个FileTimes对象上的数据克隆给自己
rust
fn clone_from(&mut self, scource: &Self)impl Debug for FileTimes
fmt
使用给定的格式化程序格式化该值。
rust
fn fmt(&self, f: &mut Formatter<'_>) -> Resultimpl Default for FileTimes
default
返回类型的 “默认值”。
rust
fn default() -> FileTimesimpl FileTimesExt for FileTimes
TIP
仅在Windows可用
set_created
设置文件的创建时间。
rust
fn set_created(self, t: SystemTime) -> Selfimpl Copy for FileTimes
3.Auto Trait Implementations
impl RefUnwindSafe for FileTimes
impl Send for FileTimes
impl Sync for FileTimes
impl Unpin for FileTimes
impl UnwindSafe for FileTimes
4.Blanket Implementations
impl<T> Any for T
rust
impl<T> Any for T
where
T: 'static + ?Sized,impl<T> Borrow<T> for T
rust
impl<T> Borrow<T> for T
where
T: ?Sized,impl<T> BorrowMut<T> for T
rust
impl<T> BorrowMut<T> for T
where
T: ?Sized,impl<T> From<T> for T
rust
impl<T> From<T> for Timpl<T, U> Into<U> for T
rust
impl<T, U> Into<U> for T
where
U: From<T>,impl<T> ToOwned for T
rust
impl<T> ToOwned for T
where
T: Clone,impl<T, U> TryFrom<U> for T
rust
impl<T, U> TryFrom<U> for T
where
U: Into<T>,impl<T, U> TryInto<U> for T
rust
impl<T, U> TryInto<U> for T
where
U: TryFrom<T>,