Skip to main content

FileObject

Struct FileObject 

Source
pub struct FileObject { /* private fields */ }
Expand description

One object’s uncompressed body in an owned file descriptor.

The body may occupy the whole file or a byte range in a shared data file. Git loose zlib files and compressed pack entries require decoding first. IDs and kinds come from the caller’s manifest; use ValidatedRepository to verify them and the complete graph. An open descriptor pins the file across renames, replacement and unlinking, but the host must prevent in-place writes for the lifetime of the repository and its URL. This is not a disk snapshot.

Implementations§

Source§

impl FileObject

Source

pub fn open_at( directory: impl AsFd, path: &CStr, kind: ObjectKind, id: ObjectId, ) -> Result<Self>

Open relative to a directory without allocating a path. The final path component must be a regular file rather than a symlink. This is ordinary openat, not confinement of arbitrary paths to the supplied directory.

Source

pub fn from_fd(fd: OwnedFd, kind: ObjectKind, id: ObjectId) -> Result<Self>

Take ownership of an open regular file; its whole current body is used.

Source

pub fn from_range( fd: OwnedFd, offset: u64, info: ObjectInfo, id: ObjectId, ) -> Result<Self>

Take ownership of an open descriptor and a raw body range. Ranges must fit the current file length and signed 64-bit native file offsets.

Source

pub fn id(&self) -> ObjectId

Source

pub fn info(&self) -> ObjectInfo

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.