pub struct Padding {
pub size: BlockSize,
}Expand description
A PADDING metadata block
Padding blocks are empty blocks consisting of all 0 bytes. If one wishes to edit the metadata in other blocks, adjusting the size of the padding block allows us to do so without have to rewrite the entire FLAC file. For example, when adding 10 bytes to a comment, we can subtract 10 bytes from the padding and the total size of all blocks remains unchanged. Therefore we can simply overwrite the old comment block with the new without affecting the following FLAC audio frames.
This block may occur multiple times in a FLAC file.
§Example
use bitstream_io::{BitReader, BitRead, BigEndian};
use flac_codec::metadata::{BlockHeader, BlockType, Padding};
let data: &[u8] = &[
0x81, 0x00, 0x00, 0x0a, // block header
// padding bytes
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
];
let mut r = BitReader::endian(data, BigEndian);
let header = r.parse::<BlockHeader>().unwrap();
assert_eq!(
&header,
&BlockHeader {
last: true,
block_type: BlockType::Padding,
size: 0x0au8.into(),
},
);
assert_eq!(
r.parse_using::<Padding>(header.size).unwrap(),
Padding {
size: 0x0au8.into(),
},
);Fields§
§size: BlockSizeThe size of the padding, in bytes
Trait Implementations§
Source§impl AsBlockRef for Padding
impl AsBlockRef for Padding
Source§fn as_block_ref(&self) -> BlockRef<'_>
fn as_block_ref(&self) -> BlockRef<'_>
Returns fresh reference to ourself.
Source§impl FromBitStreamUsing for Padding
impl FromBitStreamUsing for Padding
Source§impl MetadataBlock for Padding
impl MetadataBlock for Padding
Source§fn total_size(&self) -> Option<BlockSize>
fn total_size(&self) -> Option<BlockSize>
Size of block, in bytes, including block header
Source§impl OptionalMetadataBlock for Padding
impl OptionalMetadataBlock for Padding
Source§const OPTIONAL_TYPE: OptionalBlockType = OptionalBlockType::Padding
const OPTIONAL_TYPE: OptionalBlockType = OptionalBlockType::Padding
Our optional block type
Source§impl ToBitStream for Padding
impl ToBitStream for Padding
impl Eq for Padding
impl StructuralPartialEq for Padding
Auto Trait Implementations§
impl Freeze for Padding
impl RefUnwindSafe for Padding
impl Send for Padding
impl Sync for Padding
impl Unpin for Padding
impl UnwindSafe for Padding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more