pub struct ListRequest { /* private fields */ }
Expand description
Request a list of resources.
Implementations§
Source§impl ListRequest
impl ListRequest
Sourcepub fn new(resource_type: &str) -> Self
pub fn new(resource_type: &str) -> Self
Create a new ListRequest, fetching all resources of type resource_type
.
Use a DataSource
to execute the ListRequest
Sourcepub fn format(self, format: Format) -> Self
pub fn format(self, format: Format) -> Self
Change format of the returned data.
Can be either Format::Json
or Format::Xml
Sourcepub fn order_by(self, field: &str, direction: Direction) -> Self
pub fn order_by(self, field: &str, direction: Direction) -> Self
Order the returned resources by field
, in specified direction
. Direction::Ascending
by default.
Sourcepub fn inline_count(self, value: InlineCount) -> Self
pub fn inline_count(self, value: InlineCount) -> Self
Include an inline count field in the odata page metadata.
Useful for gauging how many results/pages are left. By default this is not specified, which implies InlineCount::None
Sourcepub fn filter(self, field: &str, comparison: Comparison, value: &str) -> Self
pub fn filter(self, field: &str, comparison: Comparison, value: &str) -> Self
Filter the returned results using an OData conditional expression.
See the OData 2.0 documentation (section 4.5) for more information.
#[derive(Deserialize, Debug)]
struct Dokument {
titel: String,
}
let page: Page<Dokument> = datasource
.fetch_paged(ListRequest::new("Dokument")
.filter("id", Comparison::Equal, "24")
).await.unwrap();
assert_eq!(page.value[0].titel, "Grund- og nærhedsnotat vedr. sanktioner på toldområdet")
Sourcepub fn expand<'f, F>(self, field: F) -> Selfwhere
F: IntoIterator<Item = &'f str>,
pub fn expand<'f, F>(self, field: F) -> Selfwhere
F: IntoIterator<Item = &'f str>,
Expand specific relations of the returned object, if possible.
For the Folketinget API for example, you can expand the DokumentAktør
field of a Dokument
, to simultaneously retrieve information about the document authors, instead of having to do two separate lookups for the DokumentAktør
relation and then the actual Aktør
.
Trait Implementations§
Source§impl Clone for ListRequest
impl Clone for ListRequest
Source§fn clone(&self) -> ListRequest
fn clone(&self) -> ListRequest
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more