pub struct Contents { /* private fields */ }
Implementations§
Source§impl Contents
impl Contents
Sourcepub fn get(&self, filepath: impl ToString) -> GetContentsRepoBuilder
pub fn get(&self, filepath: impl ToString) -> GetContentsRepoBuilder
Gets the metadata and contents (if a file) of an entry in a repository, or a list of entries if a dir This will return a list of all Entry objects
§Example
let client = Client::new(
"https://gitea.example.com",
Auth::Token("your-token")
);
let src_entries = client
.repos("repo-owner", "repo-name")
.contents()
.get("src")
.send(&client)
.await
.unwrap();
let main_file_entry = client
.repos("repo-owner", "repo-name")
.contents()
.get("src/main.rs")
.send(&client)
.await
.unwrap();
Sourcepub fn create_file(
&self,
filepath: impl ToString,
content: impl ToString,
) -> CreateFileRepoBuilder
pub fn create_file( &self, filepath: impl ToString, content: impl ToString, ) -> CreateFileRepoBuilder
Create a file in a repository This will return EntryMutation object
§Example
let client = Client::new(
"https://gitea.example.com",
Auth::Token("your-token")
);
let new_entry = client
.repos("repo-owner", "repo-name")
.contents()
.create_file("test/server.yml", BASE64_STANDARD.encode(b"port: 80"))
.send(&client)
.await
.unwrap();
Sourcepub fn update_file(
&self,
filepath: impl ToString,
content: impl ToString,
sha: impl ToString,
) -> UpdateFileRepoBuilder
pub fn update_file( &self, filepath: impl ToString, content: impl ToString, sha: impl ToString, ) -> UpdateFileRepoBuilder
Update a file in a repository This will return EntryMutation object
§Example
let client = Client::new(
"https://gitea.example.com",
Auth::Token("your-token")
);
let entries = client
.repos("repo-owner", "repo-name")
.contents()
.get("test/server.yml")
.send(&client)
.await
.unwrap();
let server_entry = &entries[0];
let entry_mutation = client
.repos("repo-owner", "repo-name")
.contents()
.update_file(
"test/server.yml",
BASE64_STANDARD.encode(b"port: 8080"),
server_entry.sha.clone(),
)
.send(&client)
.await
.unwrap();
Sourcepub fn delete_file(
&self,
filepath: impl ToString,
sha: impl ToString,
) -> DeleteFileRepoBuilder
pub fn delete_file( &self, filepath: impl ToString, sha: impl ToString, ) -> DeleteFileRepoBuilder
Delete a file in a repository This will return EntryMutation object
§Example
let client = Client::new(
"https://gitea.example.com",
Auth::Token("your-token")
);
let entries = client
.repos("repo-owner", "repo-name")
.contents()
.get("test/server.yml")
.send(&client)
.await
.unwrap();
let server_entry = &entries[0];
let entry_mutation = client
.repos("repo-owner", "repo-name")
.contents()
.delete_file("test/server.yml", server_entry.sha.clone())
.send(&client)
.await
.unwrap();
Auto Trait Implementations§
impl Freeze for Contents
impl RefUnwindSafe for Contents
impl Send for Contents
impl Sync for Contents
impl Unpin for Contents
impl UnwindSafe for Contents
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