Skip to main content

Host

Struct Host 

Source
pub struct Host<T> { /* private fields */ }
Expand description

The remote-host side of a run, over whichever store holds its state.

It is both interfaces at once: a RemoteHost a journey can call directly, and the Hosting factory a run is handed. A host taken from the factory shares this one’s state, so what a publication did is read back through the value the journey created.

Implementations§

Source§

impl Host<MemoryStore<HostState>>

Source

pub fn new() -> Self

A host with nothing opened against it.

Source

pub fn seeded(state: HostState) -> Self

A host that starts from a scenario.

Source

pub fn state(&self) -> HostState

Everything it knows.

Source§

impl Host<FileStore<HostState>>

Source

pub fn create(path: impl Into<PathBuf>) -> Result<Self>

A host keeping its state at path: whatever is already there, or nothing opened against it.

Attaching rather than replacing, so a second host over the same path answers about the change requests the first one opened.

Source

pub fn seeded(path: impl Into<PathBuf>, state: HostState) -> Result<Self>

A host that starts from a scenario, keeping its state at path and replacing whatever was there.

Source

pub fn state(&self) -> Result<HostState>

Everything it knows, read back out of its document.

Source§

impl<T: Store<HostState>> Host<T>

A person’s moves on a stack of change requests, which no interface method makes: the real host takes them from people — a merge on its page, a branch deleted, a change request closed or moved — so a journey takes them here.

Source

pub fn merge_by_person( &self, change: &ChangeId, how: PersonMerge, at: &str, head: HeadAfter, ) -> Result<Sha>

A person merges change on the host into the base it targets now — how a squash or a merge commit — at at, an RFC 3339 moment on the host’s clock, and then keeps or deletes its head as head says: a deleted head closes or retargets every open change request based on it. Answers the commit the base reached. Nothing is written to the ledger: nobody on this host made a call.

Source

pub fn close_unmerged(&self, change: &ChangeId) -> Result<()>

A person closes change on the host without merging it.

Source

pub fn retarget_by_person(&self, change: &ChangeId, base: &str) -> Result<()>

A person moves change onto base on the host.

Source

pub fn set_head_checks(&self, head: &Sha, checks: Vec<Check>) -> Result<()>

Each check’s state on one head commit, in place of the change request’s own.

Source

pub fn ledger(&self) -> Result<Vec<HostCall>>

Every host call this host answered, in order, with what GitHub charges for it.

Source§

impl<T: Store<HostState>> Host<T>

A reviewer’s moves on a change request’s feedback, which no interface method makes: the real host takes them from people, so a journey takes them here.

Source

pub fn add_comment(&self, change: &ChangeId, comment: HostComment) -> Result<()>

Post one more comment on change, as a reviewer would — a review-thread comment, a review’s summary or a conversation comment, whichever comment’s kind says. Its revision is this host’s to set, and is set past every read so far.

Source

pub fn edit_comment( &self, change: &ChangeId, comment: &CommentId, body: &str, ) -> Result<()>

Replace a comment’s body, as its author editing it would.

Source

pub fn set_thread( &self, change: &ChangeId, thread: &str, resolved: bool, outdated: bool, ) -> Result<()>

Set a review thread’s two flags, as resolving it, unresolving it, or a push moving past its line would. Every comment in the thread changes with it.

Trait Implementations§

Source§

impl<T: Debug> Debug for Host<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Store<HostState> + Clone + Debug + Send + Sync + 'static> Hosting for Host<T>

Source§

fn for_repo(&self, slug: &str) -> Result<Box<dyn RemoteHost>>

The host that answers for the repository named owner/name.
Source§

impl<T: Store<HostState>> RemoteHost for Host<T>

Source§

fn ready_for_review(&self, cr: &ChangeRequest) -> Result<()>

Take the change request out of its draft state.

The call itself is what is recorded, rather than a flag that would read the same whether it was made once or twice: what a journey asks of this is whether a second publication over an already-lifted change asked the host for anything, and only the calls can answer that. A change already open for review is already what this asks for, so it succeeds — the caller wanted it ready, and it is.

Source§

fn required_checks_on(&self, _base: &str) -> Result<RequiredChecks>

What the repository requires before a merge into base: the seeded answer, or — unset — exactly the checks seeded as required, completely.

Source§

fn describe_change( &self, cr: &ChangeRequest, title: Option<&str>, body: &str, ) -> Result<()>

Replace the description, recording the call.

The title and body go where open_change put the ones it was given, so what change_description reads back is the same record whichever call wrote it — and the call itself is kept, for the reason ready_for_review’s is: a journey about a closeout asks what was written and in what order, and the current description cannot say. A title that names nothing is refused as the real host refuses one; a body is prose, and an empty one is a description a caller may mean.

Source§

fn change_description(&self, cr: &ChangeRequest) -> Result<Description>

The description as this host holds it: the title it was opened or last described with, and the body — empty where it was opened with none and never described since, which is what the real host answers for one.

Source§

fn review_comments( &self, change: &ChangeId, since: Option<&ReadMarker>, ) -> Result<ReviewRead>

What changed in the change request’s review feedback since since, by this host’s own count of changes to it — see review.

Source§

fn reply_to_comment( &self, change: &ChangeId, comment: &CommentId, body: &str, key: &str, ) -> Result<PostedReply>

One reply, posted in the comment’s thread where it has one and as a conversation comment linking it otherwise, and recorded in HostState::replies.

Source§

fn mergeability(&self, cr: &ChangeRequest) -> Result<Mergeability>

Recorded on the ledger and answered as the trait’s default answers: this host holds no mergeability, and a publication reads the refusal as a host that said nothing, which is no conflict — so it watches as it always did here.

Source§

fn head_activity(&self, cr: &ChangeRequest) -> Result<HeadActivity>

What HostState::head_activity scripts for this call about cr, answered about the commit cr names; unscripted, nothing is running there, by every source. Charged as the two REST reads the real host makes — the workflow runs and the check suites on that commit.

Source§

fn requires_up_to_date(&self, _base: &str) -> Result<bool>

Whether this host requires an up-to-date branch: HostState::up_to_date_required. Charged as the two protection reads the real host makes.

Source§

fn allows_auto_merge(&self) -> Result<bool>

Whether the repository allows auto-merge: HostState::allow_auto_merge. Charged as the one query the real host makes.

Source§

fn visibility(&self) -> Result<Visibility>

Recorded on the ledger and answered as the trait’s default answers: this host holds no visibility, so the boundary records it unknown and screens every write, as it always did here.

Source§

fn change_standings( &self, root: &str, changes: &[ChangeId], ) -> Result<ChangeStandings>

Where each change request stands, one per change request asked about — see landings. Charged as the real host’s one query per 50.

Source§

fn review_standings( &self, root: &str, changes: &[(ChangeId, Option<ReadMarker>)], ) -> Result<ReviewStandings>

Each change request’s standing and its review feedback since its marker, in one read charged as the real host’s one aliased query per 150.

Source§

fn retarget_change( &self, change: &ChangeId, base: &str, body: Option<&str>, ) -> Result<ReadCost>

Move a change request onto base, writing body with it — refused, as the real host refuses, for one that is merged or closed and for a base the origin no longer has. Its draft state never changes. One REST request.

Source§

fn reopen_change(&self, change: &ChangeId) -> Result<ReadCost>

Reopen a closed change request, as the draft it was — refused, as the real host refuses, for one that is not closed and for one whose base is still gone. One REST request.

Source§

fn authenticated_user(&self) -> Result<String>

Who the host believes is calling.
Source§

fn open_change(&self, req: ChangeSpec) -> Result<ChangeRequest>

Open a change request.
Source§

fn find_changes(&self, head: &str, base: &str) -> Result<Vec<ChangeRequest>>

Every open change request from head into base.
Source§

fn change_checks(&self, cr: &ChangeRequest) -> Result<ChangeChecks>

The checks the host is reporting on a change request, and which of its sources that answer was read from.
Source§

fn check_log(&self, cr: &ChangeRequest, check: &Check) -> Result<ArtifactId>

Store one check’s log as an artifact and return its id.
Source§

fn merge(&self, cr: &ChangeRequest, policy: MergePolicy) -> Result<MergeOutcome>

Merge a change request under a policy.
Source§

fn is_draft(&self, cr: &ChangeRequest) -> Result<bool>

Whether the host is holding this change request as a draft. Read more
Source§

fn merge_time(&self, cr: &ChangeRequest) -> Result<Option<String>>

When the host says a merged change request reached its base, as the host spelled it, or None while it has not merged it. Read more
Source§

fn merged_head(&self, cr: &ChangeRequest) -> Result<Option<MergedChange>>

The commit a change request reached its base at and the head the host merged it from, or None while the host has not merged it. Read more
Source§

fn merged_at(&self, cr: &ChangeRequest) -> Result<Option<Sha>>

The commit a change request reached its base at, or None while the host has not merged it. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Host<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Host<T>
where T: RefUnwindSafe,

§

impl<T> Send for Host<T>
where T: Send,

§

impl<T> Sync for Host<T>
where T: Sync,

§

impl<T> Unpin for Host<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Host<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Host<T>
where T: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.