Struct ogg_magic::ogg_vorbis_page::OggVorbisPage

source ·
pub struct OggVorbisPage {
    pub ogg_page: OggPage,
}
Expand description

Represents an Ogg Vorbis page.

Fields§

§ogg_page: OggPage

Implementations§

source§

impl OggVorbisPage

source

pub fn new(buffer: Vec<u8>) -> Result<Self, VorbisFormatError>

Creates a new OggVorbisPage from the given buffer.

source

pub fn get_identification( &self, segment_index: usize, ) -> Result<IVorbisIdentificationHeader, VorbisFormatError>

Retrieves the identification header from the specified segment index.

source

pub fn is_header_packet(&self, segment_index: usize) -> bool

Checks if the specified segment is a header packet.

source

pub fn is_identification_packet(&self, segment_index: usize) -> bool

Checks if the specified segment is an identification packet.

source

pub fn is_comment_packet(&self, segment_index: usize) -> bool

Checks if the specified segment is a comment packet.

source

pub fn is_setup_packet(&self, segment_index: usize) -> bool

Checks if the specified segment is a setup packet.

source

pub fn get_comments( &self, segment_index: usize, ) -> Result<IVorbisCommentHeader, VorbisFormatError>

Retrieves the comments from the specified segment index.

source

pub fn get_setup( &self, audio_channels: u8, segment_index: usize, ) -> Result<IVorbisSetupHeader, VorbisFormatError>

Retrieves the setup header from the specified segment index.

source

pub fn remove_page_segment( &self, index: usize, n: usize, ) -> Result<Self, VorbisFormatError>

source

pub fn replace_page_segment( &self, segment: Vec<u8>, index: usize, ) -> Result<Self, VorbisFormatError>

source

pub fn build_comments(header: IVorbisCommentHeader) -> Vec<u8>

Methods from Deref<Target = OggPage>§

source

pub fn validate_page_size(&self) -> Result<(), OggFormatError>

Validates the size of the Ogg page.

§Returns
  • Result<(), OggFormatError> - Ok if the size is valid, otherwise an error.
source

pub fn get_page_segment(&self, index: usize) -> Result<Vec<u8>, OggFormatError>

Retrieves a specific segment from the Ogg page.

§Arguments
  • index - The index of the segment to retrieve.
§Returns
  • Result<Vec<u8>, OggFormatError> - The segment as a vector of bytes or an error if the index is out of range.
source

pub fn map_segments<T, F>(&self, callback: F) -> Vec<T>
where F: Fn(&[u8], usize) -> T,

Applies a callback function to each segment of the Ogg page.

§Arguments
  • callback - A function to apply to each segment.
§Returns
  • Vec<T> - A vector containing the results of applying the callback to each segment.
source

pub fn remove_page_segment_and_get_raw_result( &self, index: usize, n: usize, ) -> Result<Vec<u8>, OggFormatError>

Removes a segment from the Ogg page and returns the raw result.

§Arguments
  • index - The starting index of the segment to remove.
  • n - The number of segments to remove.
§Returns
  • Result<Vec<u8>, OggFormatError> - The new buffer as a vector of bytes or an error if the operation fails.
source

pub fn add_page_segment_and_get_raw_result( &self, segments: &[Vec<u8>], index: usize, ) -> Result<Vec<u8>, OggFormatError>

Adds segments to the Ogg page and returns the raw result.

§Arguments
  • segments - A slice of vectors, each representing a segment to add.
  • index - The index at which to add the segments.
§Returns
  • Result<Vec<u8>, OggFormatError> - The new buffer as a vector of bytes or an error if the operation fails.
source

pub fn replace_page_segment_and_get_raw_result( &self, segment: Vec<u8>, index: usize, ) -> Result<Vec<u8>, OggFormatError>

Replaces a segment in the Ogg page and returns the raw result.

§Arguments
  • segment - A vector of bytes representing the new segment.
  • index - The index of the segment to replace.
§Returns
  • Result<Vec<u8>, OggFormatError> - The new buffer as a vector of bytes or an error if the operation fails.
source

pub fn remove_page_segment( &self, index: usize, n: usize, ) -> Result<Self, OggFormatError>

Removes a segment from the Ogg page.

§Arguments
  • index - The starting index of the segment to remove.
  • n - The number of segments to remove.
§Returns
  • Result<Self, OggFormatError> - A new OggPage instance or an error if the operation fails.
source

pub fn add_page_segment( &self, segments: &[Vec<u8>], index: usize, ) -> Result<Self, OggFormatError>

Adds segments to the Ogg page.

§Arguments
  • segments - A slice of vectors, each representing a segment to add.
  • index - The index at which to add the segments.
§Returns
  • Result<Self, OggFormatError> - A new OggPage instance or an error if the operation fails.
source

pub fn replace_page_segment( &self, segment: Vec<u8>, index: usize, ) -> Result<Self, OggFormatError>

Replaces a segment in the Ogg page.

§Arguments
  • segment - A vector of bytes representing the new segment.
  • index - The index of the segment to replace.
§Returns
  • Result<Self, OggFormatError> - A new OggPage instance or an error if the operation fails.
source

pub fn calculate_page_checksum(&self) -> u32

Calculates the checksum of the Ogg page.

§Returns
  • u32 - The calculated checksum.
source

pub fn update_page_checksum(&mut self)

Updates the checksum of the Ogg page.

source

pub fn if_page_checksum_correct(&self) -> bool

Checks if the checksum of the Ogg page is correct.

§Returns
  • bool - true if the checksum is correct, false otherwise.

Trait Implementations§

source§

impl Clone for OggVorbisPage

source§

fn clone(&self) -> OggVorbisPage

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for OggVorbisPage

source§

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

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

impl DerefMut for OggVorbisPage

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl Deref for OggVorbisPage

§

type Target = OggPage

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.