Skip to main content

Fat12

Struct Fat12 

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

FAT12 table implementation.

FAT12 uses 12-bit entries packed into 3 bytes for every 2 clusters.

Implementations§

Source§

impl Fat12

Source

pub fn new(start: usize, size: usize, count: usize, max_cluster: u16) -> Self

Creates a FAT12 table descriptor.

Source

pub fn max_cluster(&self) -> u16

Get the maximum cluster number.

Source

pub fn next_cluster<T: Read + Seek>( &self, reader: &mut T, cluster: usize, ) -> Result<Option<u32>>

Returns the next cluster in a chain, or None at end-of-chain.

Source

pub fn write_clus<T: Read + Write + Seek>( &self, rw: &mut T, cluster: usize, value: u16, ) -> Result<()>

Write a cluster entry to all FAT table copies

Source

pub fn allocate_cluster<T: Read + Write + Seek>( &self, rw: &mut T, hint: u16, ) -> Result<u16>

Allocate a single cluster, returns the allocated cluster number.

Source

pub fn allocate_chain<T: Read + Write + Seek>( &self, rw: &mut T, count: usize, hint: u16, ) -> Result<u16>

Allocate a linked chain of count clusters, returning the first cluster.

Each cluster is allocated from a rolling hint (near the previous one) and linked to its successor; the last is marked end-of-chain. Mirrors Fat32::allocate_chain. On partial failure the already-allocated clusters are not rolled back (matching the FAT32 behavior).

Source

pub fn extend_chain<T: Read + Write + Seek>( &self, rw: &mut T, last: u16, count: usize, hint: u16, ) -> Result<u16>

Extend the chain whose current last cluster is last by count clusters, returning the first newly allocated cluster. If count is 0, no clusters are allocated and last is returned unchanged. Mirrors Fat32::extend_chain.

Source

pub fn free_chain<T: Read + Write + Seek>( &self, rw: &mut T, start: u16, ) -> Result<u32>

Free a cluster chain starting at start, returns count of freed clusters.

Source

pub fn truncate_chain<T: Read + Write + Seek>( &self, rw: &mut T, cluster: u16, ) -> Result<u32>

Truncate a cluster chain after the specified cluster.

The specified cluster becomes the end of chain (marked with end-of-chain marker). All clusters following it are freed.

Returns the number of clusters freed.

Source

pub fn mark_bad<T: Read + Write + Seek>( &self, rw: &mut T, cluster: u16, ) -> Result<()>

Mark a cluster as bad (0x0FF7) in all FAT copies.

Source§

impl Fat12

Source

pub fn read_entry<T: Read + Seek>( &self, reader: &mut T, cluster: usize, ) -> Result<u16>

Read a raw FAT12 entry.

Auto Trait Implementations§

§

impl Freeze for Fat12

§

impl RefUnwindSafe for Fat12

§

impl Send for Fat12

§

impl Sync for Fat12

§

impl Unpin for Fat12

§

impl UnsafeUnpin for Fat12

§

impl UnwindSafe for Fat12

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.