Skip to main content

SessionSetup

Struct SessionSetup 

Source
pub struct SessionSetup {
    pub policy: Arc<ReceivePolicy>,
    pub hooks: Option<Arc<dyn ReceiveHooks>>,
}
Expand description

The receive policy and the hooks that ReceiveAuth::open gives to a session.

Fields§

§policy: Arc<ReceivePolicy>

The receive policy of the session.

§hooks: Option<Arc<dyn ReceiveHooks>>

The hooks of the session, or None for a session with no hooks.

The endpoint opens the session with ReceiveService::hello_with_hooks. The commit of the session calls ReceiveHooks::before_update, or ReceiveHooks::before_server_commit for a server commit, before the update lock. It calls ReceiveHooks::after_update after it releases the update lock.

§Refusals and errors of a hook

  • A refusal of before_update or before_server_commit with HookRefusal::denied gets 422 with ref-denied. Hooks that do not implement before_server_commit refuse each server commit in this way.
  • A refusal of before_update or before_server_commit with HookRefusal::internal gets 500 with internal.
  • An error of after_update gets 500 with internal. The refs and the detached metadata stay written, and the session ends as aborted. The endpoint does not call EndpointOptions::on_report.

The client gets the message of the refusal or of the error in the Error frame, as the hook wrote it, cut at 4096 bytes. The host must not put secrets or internal details in the message, because the client sees it.

§Session state during a hook

While a hook runs, the session commits:

Because the response to commit waits for both hooks, the host must limit the time of its hooks.

§Checks after the hook

The commit runs these checks after before_update returns its plan, so a commit can fail after a plan from the hook:

  • Before the update lock, a plan that the checks refuse gets 500 with internal. ReceiveHooks states the checks of the plan.
  • Before the update lock, a merged dict with the host entries that is larger than the size limit gets 422 with limit-exceeded.
  • Under the update lock, these updates get 422 with ref-denied:
    • a ref that is an alias
    • a path that a ref write cannot replace
    • two updates of which one names a directory of the other
  • Under the update lock, ref-mismatch and non-fast-forward get 409, and delete-denied gets 422.
  • Under the update lock, if the stored dict changed after the plan, a merged dict over the size limit gets 422 with limit-exceeded.

The commit of a server commit runs these checks after before_server_commit returns:

  • Under the update lock, the checks of the ref paths get 422 with ref-denied.
  • Under the update lock, orphan on a branch that is present, which the policy does not allow, gets 409 with non-fast-forward.
  • Under the update lock, a tag that is present gets 409 with ref-mismatch.
  • Under the update lock, if the stored dict of a staged attachment changed after the size check before the hook, a merged dict over the size limit gets 422 with limit-exceeded.

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> 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.
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