Skip to main content

FileAttributes

Struct FileAttributes 

Source
pub struct FileAttributes { /* private fields */ }

Implementations§

Source§

impl FileAttributes

Source

pub fn builder() -> FileAttributesBuilder<((), (), (), (), (), (), (), (), (), (), (), ())>

Create a builder for building FileAttributes. On the builder, call .mode(...), .size(...)(optional), .nlink(...)(optional), .uid(...)(optional), .gid(...)(optional), .rdev(...)(optional), .blksize(...)(optional), .blocks(...)(optional), .atime(...)(optional), .mtime(...)(optional), .ctime(...)(optional), .ttl(...)(optional) to set the values of the fields. Finally, call .build() to create the instance of FileAttributes.

Examples found in repository?
examples/memfs.rs (line 51)
49    fn new(data: Vec<u8>) -> File {
50        File {
51            attrs: FileAttributes::builder()
52                .size(data.len() as u64)
53                .mode(libc::S_IFREG | 0o755)
54                .build(),
55
56            data,
57        }
58    }
Source§

impl FileAttributes

Source

pub fn mode(&self) -> u32

Source

pub fn size(&self) -> u64

Examples found in repository?
examples/memfs.rs (line 61)
60    fn size(&self) -> usize {
61        self.attrs.size() as usize
62    }
Source

pub fn uid(&self) -> u32

Source

pub fn gid(&self) -> u32

Source

pub fn rdev(&self) -> u32

Source

pub fn blksize(&self) -> u32

Source

pub fn blocks(&self) -> u64

Source

pub fn atime(&self) -> Duration

Source

pub fn mtime(&self) -> Duration

Source

pub fn ctime(&self) -> Duration

Source

pub fn ttl(&self) -> Duration

§Note

ttl means time to live This is not time to live, such as you’d go live on Twitch. It means time to live, as in the remaining time you have left alive. I spent way too long misunderstanding that.

Source

pub fn set_mode(&mut self, mode: u32)

Source

pub fn set_size(&mut self, size: u64)

Examples found in repository?
examples/memfs.rs (line 178)
165    fn write<T: BufRead>(&mut self, ino: INode, offset: u64, size: u32, mut buf: T) -> Result<u32> {
166        let file = self.inodes.get_mut(ino).ok_or(FSError::NoEntry)?;
167        let file = file.as_file_mut().ok_or(FSError::NotFile)?;
168
169        let offset = offset as usize;
170        let size = size as usize;
171
172        file.data
173            .resize(std::cmp::max(file.size(), offset + size), 0);
174
175        buf.read_exact(&mut file.data[offset..offset + size])
176            .unwrap();
177
178        file.attrs.set_size((offset + size) as u64);
179
180        Ok(size as u32)
181    }
Source

pub fn set_uid(&mut self, uid: u32)

Source

pub fn set_gid(&mut self, gid: u32)

Source

pub fn set_rdev(&mut self, rdev: u32)

Source

pub fn set_blksize(&mut self, blksize: u32)

Source

pub fn set_blocks(&mut self, blocks: u64)

Source

pub fn set_atime(&mut self, atime: Duration)

Source

pub fn set_mtime(&mut self, mtime: Duration)

Source

pub fn set_ctime(&mut self, ctime: Duration)

Source

pub fn set_ttl(&mut self, ttl: Duration)

Source

pub fn apply_attrs(&mut self, attrs: SetFileAttributes)

Examples found in repository?
examples/memfs.rs (line 188)
183    fn setattr(&mut self, ino: INode, attrs: SetFileAttributes) -> Result<FileAttributes> {
184        let entry = self.inodes.get_mut(ino).ok_or(FSError::NoEntry)?;
185
186        match entry.kind_mut() {
187            INodeKind::Directory(dir) => dir.apply_attrs(attrs),
188            INodeKind::File(file) => file.attrs.apply_attrs(attrs),
189        };
190
191        Ok(entry.getattrs())
192    }

Trait Implementations§

Source§

impl Clone for FileAttributes

Source§

fn clone(&self) -> FileAttributes

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FileAttributes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for FileAttributes

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more