pub struct DataSource<C> { /* private fields */ }
Expand description
Represents a target OData API.
Implementations§
Source§impl<C> DataSource<C>where
C: Connector,
impl<C> DataSource<C>where
C: Connector,
Sourcepub fn new<A>(
client: Client<C>,
domain: A,
base_path: Option<String>,
) -> Result<DataSource<C>, Error>
pub fn new<A>( client: Client<C>, domain: A, base_path: Option<String>, ) -> Result<DataSource<C>, Error>
Sourcepub async fn fetch<T>(&self, request: GetRequest) -> Result<T, Error>where
T: DeserializeOwned,
pub async fn fetch<T>(&self, request: GetRequest) -> Result<T, Error>where
T: DeserializeOwned,
Fetch a single resource using a GetRequest
#[derive(Deserialize)]
struct Dokument {
titel: String,
}
let dokument: Dokument = datasource.fetch(
GetRequest::new("Dokument", 24)
).await.unwrap();
assert_eq!(dokument.titel, "Grund- og nærhedsnotat vedr. sanktioner på toldområdet");
Sourcepub async fn fetch_paged<T>(
&self,
request: ListRequest,
) -> Result<Page<T>, Error>where
T: DeserializeOwned,
pub async fn fetch_paged<T>(
&self,
request: ListRequest,
) -> Result<Page<T>, Error>where
T: DeserializeOwned,
Fetch a Page
d list of resources using a ListRequest
#[derive(Deserialize)]
struct Dokument {
titel: String,
}
let page: Page<Dokument> = datasource
.fetch_paged(ListRequest::new("Dokument")
.inline_count(InlineCount::AllPages)
).await.unwrap();
assert!(page.count.unwrap().parse::<u32>().unwrap() > 0)
Trait Implementations§
Source§impl<C: Clone> Clone for DataSource<C>
impl<C: Clone> Clone for DataSource<C>
Source§fn clone(&self) -> DataSource<C>
fn clone(&self) -> DataSource<C>
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<C> !Freeze for DataSource<C>
impl<C> !RefUnwindSafe for DataSource<C>
impl<C> Send for DataSource<C>where
C: Send,
impl<C> Sync for DataSource<C>where
C: Sync,
impl<C> Unpin for DataSource<C>where
C: Unpin,
impl<C> !UnwindSafe for DataSource<C>
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