pub struct RecordedTransport { /* private fields */ }Expand description
A transport that answers from a table instead of from the network.
Public rather than #[cfg(test)] so the daemon, CLI and TUI can reuse
it. It records what it was asked, so a test can assert on the
request (the auth header and pagination parameters).
Implementations§
Source§impl RecordedTransport
impl RecordedTransport
pub fn new() -> Self
Sourcepub fn on(self, url_fragment: &str, status: u16, body: &str) -> Self
pub fn on(self, url_fragment: &str, status: u16, body: &str) -> Self
Answers any request whose URL contains url_fragment with
status/body, so a test need not spell out every query parameter
it does not care about; requests() covers the ones it does.
Sourcepub fn on_with_headers(
self,
url_fragment: &str,
status: u16,
body: &str,
headers: &[(&str, &str)],
) -> Self
pub fn on_with_headers( self, url_fragment: &str, status: u16, body: &str, headers: &[(&str, &str)], ) -> Self
Like on, plus response headers - for the Link: header both
hosts paginate with.
Sourcepub fn on_file(self, url_fragment: &str, bytes: Vec<u8>) -> Self
pub fn on_file(self, url_fragment: &str, bytes: Vec<u8>) -> Self
Answers a HttpTransport::download whose URL contains url_fragment
with bytes, in chunks of 64 KiB so the progress callback runs.
pub fn requests(&self) -> Vec<HttpRequest>
Trait Implementations§
Source§impl Default for RecordedTransport
impl Default for RecordedTransport
Source§impl HttpTransport for RecordedTransport
impl HttpTransport for RecordedTransport
Source§fn download<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: HttpRequest,
progress: &'life1 Progress<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn download<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: HttpRequest,
progress: &'life1 Progress<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Fetches a binary body (a release archive).
progress(received, total)
runs after every chunk; returning false cancels the download. The
default refuses: only transports that can stream bytes implement it.fn send<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !Freeze for RecordedTransport
impl Forget for RecordedTransport
impl Move for RecordedTransport
impl RefUnwindSafe for RecordedTransport
impl Send for RecordedTransport
impl Sync for RecordedTransport
impl Unpin for RecordedTransport
impl UnsafeUnpin for RecordedTransport
impl UnwindSafe for RecordedTransport
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