Struct domain::bits::compose::ComposeSnapshot [−][src]
pub struct ComposeSnapshot { /* fields omitted */ }
A snapshot of a composer’s state.
This type is actually a composer all by itself, that is, it implements
AsMut<Composer>
. However, if necessary, it can be rolled back to the
state the composer had when it was created forgetting about all changes
made since.
This process currently is not transitive. While a new snapshot can be created from both a composer and a snapshot, when you roll back you get a composer. Ie., you can only roll back once. This is enough for the purpose, reuse of messages when transitioning through several servers in a resolver.
Methods
impl ComposeSnapshot
[src]
impl ComposeSnapshot
pub fn new(composer: Composer) -> Self
[src]
pub fn new(composer: Composer) -> Self
Creates a new snapshot from the given composer.
pub fn rewind(&mut self)
[src]
pub fn rewind(&mut self)
Rewinds the state to when the snapshot was taken.
pub fn rollback(self) -> Composer
[src]
pub fn rollback(self) -> Composer
Rolls back to a composer with state as when the snapshot was taken.
pub fn commit(self) -> Composer
[src]
pub fn commit(self) -> Composer
Trades in the snapshot to a composer with all changes commited.
Methods from Deref<Target = Composer>
pub fn preview(&mut self) -> &[u8]
[src]
pub fn preview(&mut self) -> &[u8]
Returns a reference to the underlying vector as it looks now.
This method updates the length shim in stream mode, hence the
need for a &mut self
.
pub fn so_far(&self) -> &[u8]
[src]
pub fn so_far(&self) -> &[u8]
Returns the message bytes as far as they are assembled yet.
The returned bytes slice really only contains the message bytes and neither whatever was contained in the vector with which the composer was posssibly created nor the length prefix of stream mode.
pub fn so_far_mut(&mut self) -> &mut [u8]
[src]
pub fn so_far_mut(&mut self) -> &mut [u8]
Returns the message bytes as far as they are assembled yet.
The returned bytes slice really only contains the message bytes and neither whatever was contained in the vector with which the composer was posssibly created nor the length prefix of stream mode.
pub fn pos(&self) -> usize
[src]
pub fn pos(&self) -> usize
Returns the current position.
The returned value is identical to the current overall length of the underlying bytes vec.
pub fn start(&self) -> usize
[src]
pub fn start(&self) -> usize
Returns the position where the message starts.
This is identical to having called self.pos()
right after self
was created.
pub fn delta(&self, pos: usize) -> usize
[src]
pub fn delta(&self, pos: usize) -> usize
Returns the length of data added since the given position.
Panics
Panics if pos
is larger than the current position.
pub fn mark_checkpoint(&mut self)
[src]
pub fn mark_checkpoint(&mut self)
Marks the current position as a point for truncation.
If the length of the resulting message exceeds its predefined maximum size for the first time after a call to this method, the data will be cut back to the length it had when the method was called. If this happens, any further writing will fail.
pub fn is_truncated(&self) -> bool
[src]
pub fn is_truncated(&self) -> bool
Returns whether the target has been truncated.
pub fn compose_bytes(&mut self, data: &[u8]) -> ComposeResult<()>
[src]
pub fn compose_bytes(&mut self, data: &[u8]) -> ComposeResult<()>
Pushes a bytes slice to the end of the message.
pub fn compose_empty(&mut self, len: usize) -> ComposeResult<()>
[src]
pub fn compose_empty(&mut self, len: usize) -> ComposeResult<()>
Pushes placeholder bytes to the end of the message.
In particular, if successful, the message will have been extended
by len
octets of value zero,
pub fn compose_u8(&mut self, data: u8) -> ComposeResult<()>
[src]
pub fn compose_u8(&mut self, data: u8) -> ComposeResult<()>
Pushes a single octet to the end of the message.
pub fn compose_u16(&mut self, data: u16) -> ComposeResult<()>
[src]
pub fn compose_u16(&mut self, data: u16) -> ComposeResult<()>
Pushes an unsigned 16-bit word to the end of the message.
Since DNS data is big-endian, data
will be converted to that
endianess if necessary.
pub fn compose_u32(&mut self, data: u32) -> ComposeResult<()>
[src]
pub fn compose_u32(&mut self, data: u32) -> ComposeResult<()>
Pushes a unsigned 32-bit word to the end of the message.
Since DNS data is big-endian, data
will be converted to that
endianess if necessary.
pub fn compose_dname<N: DName>(&mut self, name: &N) -> ComposeResult<()>
[src]
pub fn compose_dname<N: DName>(&mut self, name: &N) -> ComposeResult<()>
Pushes a domain name to the end of the message.
pub fn compose_dname_compressed<N: DName>(
&mut self,
name: &N
) -> ComposeResult<()>
[src]
pub fn compose_dname_compressed<N: DName>(
&mut self,
name: &N
) -> ComposeResult<()>
pub fn update_bytes(&mut self, pos: usize, data: &[u8])
[src]
pub fn update_bytes(&mut self, pos: usize, data: &[u8])
Updates the bytes starting at the given position.
Panics
Panics if the bytes slice is longer than the data assembled since the given position.
pub fn update_u8(&mut self, pos: usize, data: u8)
[src]
pub fn update_u8(&mut self, pos: usize, data: u8)
Updates the octet at the given position.
Panics
Panics if there has not been at least one byte of data assembled since the given position.
pub fn update_u16(&mut self, pos: usize, data: u16)
[src]
pub fn update_u16(&mut self, pos: usize, data: u16)
Updates an unsigned 16-bit word starting at the given position.
Panics
Panics if there has not been at least two bytes of data assembled since the given position.
pub fn update_u32(&mut self, pos: usize, data: u32)
[src]
pub fn update_u32(&mut self, pos: usize, data: u32)
Updates an unsigned 32-bit word starting at the given position.
Panics
Panics if there has not been at least four bytes of data assembled since the given position.
Trait Implementations
impl Clone for ComposeSnapshot
[src]
impl Clone for ComposeSnapshot
fn clone(&self) -> ComposeSnapshot
[src]
fn clone(&self) -> ComposeSnapshot
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for ComposeSnapshot
[src]
impl Debug for ComposeSnapshot
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Deref for ComposeSnapshot
[src]
impl Deref for ComposeSnapshot
type Target = Composer
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
fn deref(&self) -> &Self::Target
Dereferences the value.
impl DerefMut for ComposeSnapshot
[src]
impl DerefMut for ComposeSnapshot
impl AsRef<Composer> for ComposeSnapshot
[src]
impl AsRef<Composer> for ComposeSnapshot
impl AsMut<Composer> for ComposeSnapshot
[src]
impl AsMut<Composer> for ComposeSnapshot
Auto Trait Implementations
impl Send for ComposeSnapshot
impl Send for ComposeSnapshot
impl Sync for ComposeSnapshot
impl Sync for ComposeSnapshot