| 117 | /// Abstract interface to interact with an EndBASIC service server. |
| 118 | #[async_trait(?Send)] |
| 119 | pub trait Service { |
| 120 | /// Interactively creates an account based on the details provided in `request`. |
| 121 | async fn signup(&mut self, request: &SignupRequest) -> io::Result<()>; |
| 122 | |
| 123 | /// Sends an authentication request to the service with `username` and `password` to obtain an |
| 124 | /// access token for the session. |
| 125 | /// |
| 126 | /// If logging is successful, the access token is cached for future retrieval. |
| 127 | async fn login(&mut self, username: &str, password: &str) -> io::Result<LoginResponse>; |
| 128 | |
| 129 | /// Logs out from the service and clears the access token from this object. |
| 130 | async fn logout(&mut self) -> io::Result<()>; |
| 131 | |
| 132 | /// Checks if there is an active session against the service. |
| 133 | fn is_logged_in(&self) -> bool; |
| 134 | |
| 135 | /// Returns the logged in username if there is an active session. |
| 136 | fn logged_in_username(&self) -> Option<String>; |
| 137 | |
| 138 | /// Sends a request to the server to obtain the list of files owned by `username` with a |
| 139 | /// previously-acquired `access_token`. |
| 140 | async fn get_files(&mut self, username: &str) -> io::Result<GetFilesResponse>; |
| 141 | |
| 142 | /// Sends a request to the server to obtain the contents of `filename` owned by `username` with a |
| 143 | /// previously-acquired `access_token`. |
| 144 | async fn get_file(&mut self, username: &str, filename: &str) -> io::Result<Vec<u8>>; |
| 145 | |
| 146 | /// Sends a request to the server to obtain the ACLs of `filename` owned by `username` with a |
| 147 | /// previously-acquired `access_token`. |
| 148 | async fn get_file_acls(&mut self, username: &str, filename: &str) -> io::Result<FileAcls>; |
| 149 | |
| 150 | /// Sends a request to the server to update the contents of `filename` owned by `username` as |
| 151 | /// specified in `content` with a previously-acquired `access_token`. |
| 152 | async fn patch_file_content( |
| 153 | &mut self, |
| 154 | username: &str, |
| 155 | filename: &str, |
| 156 | content: Vec<u8>, |
| 157 | ) -> io::Result<()>; |
| 158 | |
| 159 | /// Sends a request to the server to update the ACLs of `filename` owned by `username` as |
| 160 | /// specified in `add` and `remove` with a previously-acquired `access_token`. |
| 161 | async fn patch_file_acls( |
| 162 | &mut self, |
| 163 | username: &str, |
| 164 | filename: &str, |
| 165 | add: &FileAcls, |
| 166 | remove: &FileAcls, |
| 167 | ) -> io::Result<()>; |
| 168 | |
| 169 | /// Sends a request to the server to delete `filename` owned by `username` with a |
| 170 | /// previously-acquired `access_token`. |
| 171 | async fn delete_file(&mut self, username: &str, filename: &str) -> io::Result<()>; |
| 172 | } |
nothing calls this directly
no outgoing calls
no test coverage detected