Skip to main content

NativeStack

Struct NativeStack 

Source
pub struct NativeStack {
    pub number: u64,
    pub base: String,
    pub layers: Vec<NativeStackLayer>,
}
Expand description

A stack as the platform records it: its layers bottom first - the order it lands in - and the branch the bottom one targets. Read-only here; registering one is a separate step, gated behind stk.githubStacks.

Fields§

§number: u64

The platform’s own number for the stack, for messages.

§base: String

The branch the bottom review targets.

§layers: Vec<NativeStackLayer>

Layers bottom first.

Verified live rather than assumed: registering three chained pull requests (main <- p <- q <- r) lists them in exactly that order, and POST /stacks/{n}/add appends - a fourth review arrives last. That append-only behaviour is why plan_stack_registration will only extend a stack the submitted line grew on top of; /add carries no position, so it cannot express anything else.

Implementations§

Source§

impl NativeStack

Source

pub fn parent_is_current(&self, branch: &str) -> bool

Whether this stack’s own answer for branch’s parent is still current.

It is not, once that parent’s own review has landed: the platform keeps a landed layer listed, so the ordering keeps naming it forever, while the platform has already retargeted branch away from it. The stack’s base is always current - it is a branch, not a layer, and nothing lands it out from under the stack.

Source

pub fn parent_landed(&self, branch: &str, parent: &str) -> bool

Whether parent is branch’s own recorded predecessor and has landed - so the platform has already moved this base off it and will never put it back.

The exact case NativeStack::can_base_on stops accepting, which is what makes the two complementary: some other landed layer says nothing about where this review’s base went.

Source

pub fn can_base_on(&self, branch: &str, parent: &str) -> bool

Whether this stack can still bring branch’s base to parent on its own - parent is one of the two places the platform puts a base: the layer recorded directly below branch, or the stack’s own base, which is where every layer ends up once the ones beneath it land.

This is the question every caller has, and it needs the local parent to answer. A base and a parent that disagree while the stack can still close the gap is a chain part-way through unwinding: the platform retargets each layer onto the stack’s base as the one below it lands, and cleanup walks the local parents the same way. A parent the stack cannot reach - a line re-rooted onto a release branch, say - is a disagreement nothing will resolve, and callers say so instead of waiting for it.

Source

pub fn parent_of(&self, branch: &str) -> Option<&str>

What branch stacks on according to the platform: the branch below it, or the stack’s base when it is the bottom. None when the stack does not hold branch at all.

Source

pub fn position_of(&self, branch: &str) -> Option<u32>

Where branch sits in the stack, 1-based and bottom first - the same number GraphQL reports as stackEntry.position. The one derivation from this side, so the two sources cannot drift into disagreeing.

Source

pub fn review_id_for(&self, branch: &str) -> Option<&str>

The review id recorded for branch, for messages.

Trait Implementations§

Source§

impl Clone for NativeStack

Source§

fn clone(&self) -> NativeStack

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NativeStack

Source§

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

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

impl Eq for NativeStack

Source§

impl PartialEq for NativeStack

Source§

fn eq(&self, other: &NativeStack) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for NativeStack

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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, <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