pub struct ChangeClient { /* private fields */ }Expand description
Client for change-based file operations (/{org}/{repo}/changes).
Uses the gRPC ControlService to create changes, apply file operations
(create, modify, delete, move), and snapshot changes into commits.
§Example
use mesa_dev::MesaClient;
let client = MesaClient::builder()
.build()?;
let org = client.org("my-org");
let repo = org.repos().at("my-repo");
let change_client = repo.change().await?;
// Create a change based on main branch
let change = change_client.create_from_ref("refs/heads/main").await?;
let change_id = change.id.unwrap();
// Apply file operations
change_client.create_file(
&change_id,
"hello.txt",
b"Hello, world!",
None,
).await?;
// Snapshot to a commit
change_client.snapshot(&change_id, "Add hello.txt").await?;Implementations§
Source§impl ChangeClient
impl ChangeClient
Sourcepub async fn create_from_ref(
&self,
base_ref_name: &str,
) -> Result<Change, Status>
pub async fn create_from_ref( &self, base_ref_name: &str, ) -> Result<Change, Status>
Create a new change based on a ref name (e.g. "refs/heads/main").
§Errors
Returns a gRPC error if the request fails.
Sourcepub async fn create_file(
&self,
change_id: &ChangeId,
path: &str,
content: &[u8],
mode: Option<u32>,
) -> Result<ApplyOpsResponse, Status>
pub async fn create_file( &self, change_id: &ChangeId, path: &str, content: &[u8], mode: Option<u32>, ) -> Result<ApplyOpsResponse, Status>
Sourcepub async fn modify_file(
&self,
change_id: &ChangeId,
path: &str,
content: &[u8],
) -> Result<ApplyOpsResponse, Status>
pub async fn modify_file( &self, change_id: &ChangeId, path: &str, content: &[u8], ) -> Result<ApplyOpsResponse, Status>
Modify an existing file in the working copy of a change.
Replaces the file content with content (inline data).
§Errors
Returns a gRPC error if the request fails.
Sourcepub async fn delete_path(
&self,
change_id: &ChangeId,
path: &str,
recursive: bool,
) -> Result<ApplyOpsResponse, Status>
pub async fn delete_path( &self, change_id: &ChangeId, path: &str, recursive: bool, ) -> Result<ApplyOpsResponse, Status>
Delete a path from the working copy of a change.
Set recursive to true to delete a directory and all its contents.
§Errors
Returns a gRPC error if the request fails.
Sourcepub async fn move_path(
&self,
change_id: &ChangeId,
from_path: &str,
to_path: &str,
) -> Result<ApplyOpsResponse, Status>
pub async fn move_path( &self, change_id: &ChangeId, from_path: &str, to_path: &str, ) -> Result<ApplyOpsResponse, Status>
Move (rename) a path in the working copy of a change.
§Errors
Returns a gRPC error if the request fails.
Sourcepub async fn apply_ops(
&self,
change_id: &ChangeId,
ops: Vec<Op>,
) -> Result<ApplyOpsResponse, Status>
pub async fn apply_ops( &self, change_id: &ChangeId, ops: Vec<Op>, ) -> Result<ApplyOpsResponse, Status>
Apply a batch of operations to a change in a single RPC.
This is the low-level method underlying create_file,
modify_file, delete_path, and
move_path. Use it when you need to apply multiple
operations atomically.
§Errors
Returns a gRPC error if the request fails.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ChangeClient
impl !RefUnwindSafe for ChangeClient
impl Send for ChangeClient
impl Sync for ChangeClient
impl Unpin for ChangeClient
impl UnsafeUnpin for ChangeClient
impl !UnwindSafe for ChangeClient
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request