pub fn push_event<const MAX_SIZE: usize>(
        &mut self,
        event: &LV2AtomEventBuilder<MAX_SIZE>,
    ) -> Result<(), EventError> {
        let event_size =
            std::mem::size_of::<lv2_raw::LV2AtomEvent>() as u32 + event.event.body.size;
        let sequence = unsafe { &mut *self.as_mut_ptr() };
        // This size includes the atom sequence header.
        let current_sequence_size =
            std::mem::size_of_val(&sequence.atom) as u32 + sequence.atom.size;
        if (self.buffer.len() as u32) < current_sequence_size + event_size {
            return Err(EventError::SequenceFull {
                capacity: self.capacity() as usize,
                requested: (current_sequence_size + event_size) as usize,
            });
        }
        let end = unsafe { lv2_raw::lv2_atom_sequence_end(&sequence.body, sequence.atom.size) }
            as *mut lv2_raw::LV2AtomEvent;
        let src_ptr: *const u8 = event.as_ptr().cast();
        let dst_ptr: *mut u8 = end.cast();
        unsafe { std::ptr::copy_nonoverlapping(src_ptr, dst_ptr, event_size as usize) };
        // This size only includes the sequencey body.
        sequence.atom.size += lv2_raw::lv2_atom_pad_size(event_size);
        Ok(())
    }
/// Append an event to the sequence. If there is no capacity for it, then it
/// will not be appended.
///
/// # Errors
/// Returns an error if the event could not be pushed to the sequence.
Append an event to the sequence. If there is no capacity for it, then it
will not be appended.
Append an event to the sequence . If there is no capacity for it then it will not be appended .
pub fn push_event<const MAX_SIZE: usize>(
        &mut self,
        event: &LV2AtomEventBuilder<MAX_SIZE>,
    ) -> Result<(), EventError> {
        let event_size =
            std::mem::size_of::<lv2_raw::LV2AtomEvent>() as u32 + event.event.body.size;
        let sequence = unsafe { &mut *self.as_mut_ptr() };
        // This size includes the atom sequence header.
        let current_sequence_size =
            std::mem::size_of_val(&sequence.atom) as u32 + sequence.atom.size;
        if (self.buffer.len() as u32) < current_sequence_size + event_size {
            return Err(EventError::SequenceFull {
                capacity: self.capacity() as usize,
                requested: (current_sequence_size + event_size) as usize,
            });
        }
        let end = unsafe { lv2_raw::lv2_atom_sequence_end(&sequence.body, sequence.atom.size) }
            as *mut lv2_raw::LV2AtomEvent;
        let src_ptr: *const u8 = event.as_ptr().cast();
        let dst_ptr: *mut u8 = end.cast();
        unsafe { std::ptr::copy_nonoverlapping(src_ptr, dst_ptr, event_size as usize) };
        // This size only includes the sequencey body.
        sequence.atom.size += lv2_raw::lv2_atom_pad_size(event_size);
        Ok(())
    }
pub fn push_event < const MAX_SIZE : usize > ( & mut self , event : & LV2AtomEventBuilder < MAX_SIZE > , ) -> Result < ( ) , EventError > { let event_size = std :: mem :: size_of :: < lv2_raw :: LV2AtomEvent > ( ) as u32 + event . event . body . size ; let sequence = unsafe { & mut * self . as_mut_ptr ( ) } ; // This size includes the atom sequence header. let current_sequence_size = std :: mem :: size_of_val ( & sequence . atom ) as u32 + sequence . atom . size ; if ( self . buffer . len ( ) as u32 ) < current_sequence_size + event_size { return Err ( EventError :: SequenceFull { capacity : self . capacity ( ) as usize , requested : ( current_sequence_size + event_size ) as usize , } ) ; } let end = unsafe { lv2_raw :: lv2_atom_sequence_end ( & sequence . body , sequence . atom . size ) } as * mut lv2_raw :: LV2AtomEvent ; let src_ptr : * const u8 = event . as_ptr ( ) . cast ( ) ; let dst_ptr : * mut u8 = end . cast ( ) ; unsafe { std :: ptr :: copy_nonoverlapping ( src_ptr , dst_ptr , event_size as usize ) } ; // This size only includes the sequencey body. sequence . atom . size += lv2_raw :: lv2_atom_pad_size ( event_size ) ; Ok ( ( ) ) }
Append an event to the sequence.
Append an event to the sequence .
&mut self
event
&LV2AtomEventBuilder<MAX_SIZE>
&mut self
event
&LV2AtomEventBuilder<MAX_SIZE>
errors
Returns an error if the event could not be pushed to the sequence.
Returns an error if the event could not be pushed to the sequence .