pub struct Canvas { /* private fields */ }Expand description
The Canvas LMS API client. All interaction starts here.
§Example
let canvas = canvas_lms_api::Canvas::new("https://canvas.example.edu", "my-token")?;
let course = canvas.get_course(1).await?;
println!("{}", course.name.unwrap_or_default());Implementations§
Source§impl Canvas
impl Canvas
Sourcepub fn new(base_url: &str, access_token: &str) -> Result<Self>
pub fn new(base_url: &str, access_token: &str) -> Result<Self>
Create a new Canvas client.
base_url should be the institution root (e.g. https://canvas.example.edu),
not including /api/v1.
Sourcepub fn with_client(
base_url: &str,
access_token: &str,
client: Client,
) -> Result<Self>
pub fn with_client( base_url: &str, access_token: &str, client: Client, ) -> Result<Self>
Create a Canvas client with a custom reqwest::Client (for proxy, TLS config, etc.).
Sourcepub async fn get_course(&self, course_id: u64) -> Result<Course>
pub async fn get_course(&self, course_id: u64) -> Result<Course>
Sourcepub fn get_courses(&self) -> PageStream<Course>
pub fn get_courses(&self) -> PageStream<Course>
Sourcepub async fn create_course(
&self,
account_id: u64,
params: CreateCourseParams,
) -> Result<Course>
pub async fn create_course( &self, account_id: u64, params: CreateCourseParams, ) -> Result<Course>
Sourcepub async fn delete_course(&self, course_id: u64) -> Result<Course>
pub async fn delete_course(&self, course_id: u64) -> Result<Course>
Delete a course by ID. Canvas returns the deleted course object.
§Canvas API
DELETE /api/v1/courses/:id
Sourcepub async fn get_user(&self, user_id: UserId) -> Result<User>
pub async fn get_user(&self, user_id: UserId) -> Result<User>
Fetch a single user by ID or UserId::Current for the authenticated user.
§Canvas API
GET /api/v1/users/:id
Sourcepub async fn get_current_user(&self) -> Result<CurrentUser>
pub async fn get_current_user(&self) -> Result<CurrentUser>
Sourcepub async fn create_user(
&self,
account_id: u64,
params: CreateUserParams,
) -> Result<User>
pub async fn create_user( &self, account_id: u64, params: CreateUserParams, ) -> Result<User>
Sourcepub async fn get_account(&self, account_id: u64) -> Result<Account>
pub async fn get_account(&self, account_id: u64) -> Result<Account>
Sourcepub async fn get_outcome(&self, outcome_id: u64) -> Result<Outcome>
pub async fn get_outcome(&self, outcome_id: u64) -> Result<Outcome>
Sourcepub fn get_accounts(&self) -> PageStream<Account>
pub fn get_accounts(&self) -> PageStream<Account>
Auto Trait Implementations§
impl Freeze for Canvas
impl !RefUnwindSafe for Canvas
impl Send for Canvas
impl Sync for Canvas
impl Unpin for Canvas
impl UnsafeUnpin for Canvas
impl !UnwindSafe for Canvas
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