Skip to main content

Endpoint

Enum Endpoint 

Source
pub enum Endpoint {
    Account,
    Mock(MockBase),
}
Expand description

Which UpCloud answers. Built only by Endpoint::account (refuses in a mock-carrying shell) or Endpoint::mock (refuses anything off loopback).

Variants§

§

Account

https://api.upcloud.com/1.3. Real machines, a real bill.

§

Mock(MockBase)

A mock-upcloud on loopback. The base always ends /1.3.

Implementations§

Source§

impl Endpoint

Source

pub fn account() -> Result<Endpoint, String>

The account — unless the shell carries a mock variable, in which case the run does not start. An operator who exported MOCK_BASE_ENV for a fake run and then typed a real verb in the same shell used to get writes to the account from some clients and to the fake from others.

Source

pub fn account_given( env: impl Fn(&str) -> Option<String>, ) -> Result<Endpoint, String>

Endpoint::account over an injected environment, for tests.

Source

pub fn mock(base: &str) -> Result<Endpoint, String>

A mock-upcloud at base. Loopback or nothing: a fake that can be pointed off this machine is a fake that can be pointed at something real. http://127.0.0.1:8099 and http://127.0.0.1:8099/1.3 are the same door.

Source

pub fn for_base(base: &str) -> Result<Endpoint, String>

A configured base, read as a choice. For a caller whose selection is a CONFIG value rather than a verb (monetize-cloud-impl’s api_base): the account’s own base — with or without /1.3, with or without a trailing slash — is THE ACCOUNT; a loopback base is a mock; anything else is refused by name, because a client that can be pointed at an arbitrary host can be pointed at something real that is not the account.

Source

pub fn mock_from_env() -> Result<Endpoint, String>

A mock from MOCK_BASE_ENV, for a run that has ALREADY been selected as a mock run by what the operator typed. Unset is a refusal by name.

Source

pub fn is_account(&self) -> bool

Source

pub fn base_for_display(&self) -> &str

Where /… goes — for a report. Never build a request from it; hold an implementation from connect instead.

Source

pub fn banner(&self) -> String

The one line that goes at the top of anything a person might read as a measurement of the account.

Source

pub fn child_args(&self) -> Vec<String>

The argv a parent hands a CHILD process so the child makes the same choice: ["--mock-api", base] for a mock, nothing for the account. A child that receives nothing and finds a mock variable in its environment refuses (Endpoint::account) — which is how the choice cannot be lost crossing a process boundary.

Source§

impl Endpoint

Source

pub fn from_flag(mock_api: Option<&str>) -> Result<Endpoint, String>

A child’s side of Endpoint::child_args: Some(base) from --mock-api is the mock (loopback-checked); None is the account (and refuses in a mock-carrying shell). There is no third answer.

Trait Implementations§

Source§

impl Clone for Endpoint

Source§

fn clone(&self) -> Self

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 Endpoint

Source§

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

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

impl Eq for Endpoint

Source§

impl PartialEq for Endpoint

Source§

fn eq(&self, other: &Self) -> 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 Endpoint

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, 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> 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, !>

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.