[][src]Struct asuran::repository::backend::common::segment::Segment

pub struct Segment<T: Read + Write + Seek> {
    data_handle: SegmentDataPart<T>,
    header_handle: SegmentHeaderPart<T>,

Generic segment implementation wrapping any Read + Write + Seek


data_handle: SegmentDataPart<T>header_handle: SegmentHeaderPart<T>


impl<T: Read + Write + Seek + Debug> Segment<T>[src]

pub fn new(
    data_handle: T,
    header_handle: T,
    size_limit: u64,
    chunk_settings: ChunkSettings,
    key: Key
) -> Result<Segment<T>>

Creates a new segment given a reader and a maximum size

pub fn size(&mut self) -> u64[src]

Returns the size in bytes of the segment

pub fn free_bytes(&mut self) -> u64[src]

Returns the number of bytes of free space remaining in the segment

pub fn read_chunk(&mut self, index: u64) -> Result<Chunk>[src]

Reads the chunk with the specified index from the segment

pub fn write_chunk(&mut self, chunk: Chunk) -> Result<u64>[src]

pub fn read_header(&mut self) -> Result<Header>[src]

pub fn flush(&mut self) -> Result<()>[src]

Trait Implementations

impl<T: Debug + Read + Write + Seek> Debug for Segment<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Segment<T> where
    T: RefUnwindSafe

impl<T> Send for Segment<T> where
    T: Send

impl<T> Sync for Segment<T> where
    T: Sync

impl<T> Unpin for Segment<T> where
    T: Unpin

impl<T> UnwindSafe for Segment<T> where
    T: UnwindSafe

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]