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 fetch_bytes<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpBytes>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn fetch_bytes<'life0, 'async_trait>(
&'life0 self,
request: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpBytes>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Answers from the files table (200), else from the responses table (its status, headers and body as bytes).
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 RecordedTransportwhere
Mutex<Vec<(String, HttpResponse)>>: RefUnwindSafe,
Mutex<Vec<(String, Vec<u8>)>>: RefUnwindSafe,
Mutex<Vec<HttpRequest>>: RefUnwindSafe,
impl Send for RecordedTransport
impl Sync for RecordedTransport
impl Unpin for RecordedTransport
impl UnsafeUnpin for RecordedTransportwhere
Align4<u32>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<(String, HttpResponse)>: UnsafeUnpin,
PhantomData<(String, Vec<u8>)>: UnsafeUnpin,
PhantomData<HttpRequest>: UnsafeUnpin,
impl UnwindSafe for RecordedTransportwhere
Mutex<Vec<(String, HttpResponse)>>: UnwindSafe,
Mutex<Vec<(String, Vec<u8>)>>: UnwindSafe,
Mutex<Vec<HttpRequest>>: UnwindSafe,
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