Skip to main content

ChangeClient

Struct ChangeClient 

Source
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

Source

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.

Source

pub async fn create_from_commit( &self, commit_oid: &[u8], ) -> Result<Change, Status>

Create a new change based on a commit OID.

§Errors

Returns a gRPC error if the request fails.

Source

pub async fn create_file( &self, change_id: &ChangeId, path: &str, content: &[u8], mode: Option<u32>, ) -> Result<ApplyOpsResponse, Status>

Create a file in the working copy of a change.

Uses inline data for the file content. For large files, use apply_ops with an OpCreateFile referencing a pre-uploaded blob OID.

mode defaults to 0o100644 (regular file) if None.

§Errors

Returns a gRPC error if the request fails.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn snapshot( &self, change_id: &ChangeId, message: &str, ) -> Result<SnapshotChangeResponse, Status>

Snapshot the current working-copy state of a change into a commit.

§Errors

Returns a gRPC error if the request fails.

Trait Implementations§

Source§

impl Debug for ChangeClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more