pub trait StreamObserver {
// Provided methods
fn begin(&mut self) { ... }
fn before_read(&mut self) -> ObserverDecision { ... }
fn before_write(&mut self, _: &[u8]) -> ObserverDecision { ... }
fn after_write(&mut self, _: &[u8]) -> ObserverDecision { ... }
fn end(&mut self, _: usize, _: Option<Box<&dyn Error>>) { ... }
}
Expand description
Observe a stream’s operation when user code is not involved. For example: When you call EhRead.stream_to function, and you may want to calculate the checksum (SHA1, SHA256 or MD5 along the way, you can observe the stream copy using the observer)
Provided Methods§
Sourcefn begin(&mut self)
fn begin(&mut self)
Your observer’s begin will be called before stream copy If you plan to reuse the observer, you can reset it here
Sourcefn before_read(&mut self) -> ObserverDecision
fn before_read(&mut self) -> ObserverDecision
Before the upstream is read. If you want to abort, abort it here by overriding the before_read()
Sourcefn before_write(&mut self, _: &[u8]) -> ObserverDecision
fn before_write(&mut self, _: &[u8]) -> ObserverDecision
A chunk of data had been read from upstream, about to be written now You can intercept it by aborting it here
Sourcefn after_write(&mut self, _: &[u8]) -> ObserverDecision
fn after_write(&mut self, _: &[u8]) -> ObserverDecision
A chunk of data had been written to down stream. You can intercept it by aborting it here