moonrockz/mission-control-server/core does not have a README file

    AddressError

    pub(all) suberror AddressError {
    NotServerAddress(String)
    } derive(Eq,
    Debug
    )

    Raised when a text is not the address of a server. It has the text.

    BaseFolderError

    pub(all) suberror BaseFolderError {
    MissingVariable(String)
    NotAbsolute(variable~ : String, value~ : String)
    } derive(Eq,
    Debug
    )

    Raised when the environment does not give a base folder.

    FolderPathError

    pub(all) suberror FolderPathError {
    EmptyPath
    RelativePath(String)
    } derive(Eq,
    Debug
    )

    Raised when a text is not an absolute folder path.

    PortError

    pub(all) suberror PortError {
    OutOfRange(Int)
    } derive(Eq,
    Debug
    )

    Raised when a number is not a port.

    ProjectFileError

    pub(all) suberror ProjectFileError {
    Damaged(String)
    NewerFormat(Int)
    } derive(Eq,
    Debug
    )

    Raised when a text is not a project file that this version can read.

    ProjectFileError::equal

    automatically derived

    ProjectFileError::not_equal

    fn ProjectFileError::not_equal(x : ProjectFileError, y : ProjectFileError) -> Bool
    automatically derived

    ProjectFileError::to_repr

    automatically derived

    ProjectRefError

    pub(all) suberror ProjectRefError {
    NoMatch(String)
    Ambiguous(String, ReadOnlyArray[
    Project
    ])
    InvalidRef(String)
    } derive(Eq,
    Debug
    )

    Raised when a text does not select one project.

    ProjectRefError::equal

    automatically derived

    ProjectRefError::not_equal

    fn ProjectRefError::not_equal(x : ProjectRefError, y : ProjectRefError) -> Bool
    automatically derived

    ProjectRefError::to_repr

    automatically derived

    SecretError

    pub(all) suberror SecretError {
    TooShort(Int)
    } derive(Eq,
    Debug
    )

    Raised when bytes are not a secret. It never has the bytes.

    SecretError::equal

    fn SecretError::equal(SecretError, SecretError) -> Bool
    automatically derived

    SecretError::not_equal

    fn SecretError::not_equal(x : SecretError, y : SecretError) -> Bool
    automatically derived

    SecretError::to_repr

    automatically derived

    ServerRecordError

    pub(all) suberror ServerRecordError {
    Damaged(RecordDamage)
    NewerFormat(Int)
    } derive(Eq,
    Debug
    )

    Raised when a text is not a server record that this version can read.

    ServerRecordError::equal

    automatically derived

    ServerRecordError::not_equal

    fn ServerRecordError::not_equal(x : ServerRecordError, y : ServerRecordError) -> Bool
    automatically derived

    ServerRecordError::to_repr

    automatically derived

    UnknownProject

    Raised when no project in the list has the ID.

    UnknownProject::equal

    automatically derived

    UnknownProject::not_equal

    fn UnknownProject::not_equal(x : UnknownProject, y : UnknownProject) -> Bool
    automatically derived

    UnknownProject::to_repr

    automatically derived

    BaseFolder

    type BaseFolder derive(Eq,
    Debug
    )

    The folder that holds the folders of all instances.

    BaseFolder::desktop

    The folder of the desktop app that is installed for an instance.

    BaseFolder::equal

    fn BaseFolder::equal(BaseFolder, BaseFolder) -> Bool
    automatically derived

    BaseFolder::instance

    The folder of one instance.

    BaseFolder::instances

    fn BaseFolder::instances(self : BaseFolder) -> String

    The text of the folder that holds one folder for each instance.

    BaseFolder::not_equal

    fn BaseFolder::not_equal(x : BaseFolder, y : BaseFolder) -> Bool
    automatically derived

    BaseFolder::of_env

    fn BaseFolder::of_env(platform : Platform, env : Map[String, String]) -> BaseFolder raise BaseFolderError

    Finds the base folder from the environment. The caller reads the variables; this function does no I/O.

    MISSION_CONTROL_HOME wins over all other variables. Then Windows uses LOCALAPPDATA, macOS uses HOME, and Linux uses XDG_DATA_HOME or HOME. A variable with an empty value counts as not set. A relative XDG_DATA_HOME is ignored, as the XDG standard says. Another variable with a path that is not absolute raises NotAbsolute.

    BaseFolder::to_repr

    automatically derived

    CookieName

    type CookieName derive(Eq,
    Debug
    )

    The name of the session cookie of one server, such as mc_stable_3090.

    A browser sends a cookie to each port of the machine, so the name has the instance and the port. Both parts have only characters that a cookie name can have.

    CookieName::CookieName

    Makes the cookie name of a server.

    CookieName::equal

    fn CookieName::equal(CookieName, CookieName) -> Bool
    automatically derived

    CookieName::not_equal

    fn CookieName::not_equal(x : CookieName, y : CookieName) -> Bool
    automatically derived

    CookieName::to_repr

    automatically derived

    Entry

    A folder in a project list.

    Entry::equal

    fn Entry::equal(Entry, Entry) -> Bool
    automatically derived

    Entry::not_equal

    fn Entry::not_equal(x : Entry, y : Entry) -> Bool
    automatically derived

    Entry::to_repr

    automatically derived

    FolderPath

    type FolderPath derive(Eq,
    Debug
    )

    The absolute path of a folder, in one clean form: no . or .. parts, no repeated or trailing separators, and, on Windows, the separator \ and an upper-case drive letter.

    == compares the clean text. Use same_folder to compare folders: on Windows it ignores the case of letters.

    FolderPath::FolderPath

    fn FolderPath::FolderPath(text : String, platform : Platform) -> FolderPath raise FolderPathError

    Parses an absolute folder path and makes it clean. On Windows, the text can have one pair of double quotes around the path.

    FolderPath::contains

    fn FolderPath::contains(self : FolderPath, other : FolderPath) -> Bool

    True when other is this folder or is below it. A folder that has the start of the name is not below it: /code/docs does not hold /code/docs-old. The paths of two platforms never hold each other.

    FolderPath::equal

    fn FolderPath::equal(FolderPath, FolderPath) -> Bool
    automatically derived

    FolderPath::name

    fn FolderPath::name(self : FolderPath) -> String

    The name of the folder. The root has its own text as its name.

    FolderPath::not_equal

    fn FolderPath::not_equal(x : FolderPath, y : FolderPath) -> Bool
    automatically derived

    FolderPath::parent_name

    fn FolderPath::parent_name(self : FolderPath) -> String?

    The name of the folder that holds this folder: the root text for a folder at the top, and None for the root.

    FolderPath::resolve

    fn FolderPath::resolve(text : String, base : FolderPath) -> FolderPath raise FolderPathError

    Reads a path from a base folder. An absolute text gives its own folder and ignores the base. A relative text starts at the base. On Windows, a text with a root and no drive (\a) uses the drive or share of the base, and the text can have one pair of double quotes around the path.

    FolderPath::same_folder

    fn FolderPath::same_folder(self : FolderPath, other : FolderPath) -> Bool

    True when both paths are one folder. Windows ignores the case of letters. Linux and macOS compare the exact text.

    FolderPath::to_repr

    automatically derived

    FolderPath::to_string

    fn FolderPath::to_string(self : FolderPath) -> String

    The clean text of the path.

    Grant

    What a link gives to the view that opens it.

    Grant::equal

    fn Grant::equal(Grant, Grant) -> Bool
    automatically derived

    Grant::not_equal

    fn Grant::not_equal(x : Grant, y : Grant) -> Bool
    automatically derived

    Grant::to_repr

    automatically derived

    InstanceFolder

    type InstanceFolder derive(Eq,
    Debug
    )

    The folder of one instance, and the paths of its four files.

    InstanceFolder::equal

    automatically derived

    InstanceFolder::lock

    fn InstanceFolder::lock(self : InstanceFolder) -> String

    server.lock: empty; the server holds a lock on it.

    InstanceFolder::log

    fn InstanceFolder::log(self : InstanceFolder) -> String

    server.log: the output of the background process.

    InstanceFolder::not_equal

    fn InstanceFolder::not_equal(x : InstanceFolder, y : InstanceFolder) -> Bool
    automatically derived

    InstanceFolder::path

    fn InstanceFolder::path(self : InstanceFolder) -> String

    The text of the folder.

    InstanceFolder::platform

    fn InstanceFolder::platform(self : InstanceFolder) -> Platform

    InstanceFolder::projects

    fn InstanceFolder::projects(self : InstanceFolder) -> String

    projects.json: the project list.

    InstanceFolder::record

    fn InstanceFolder::record(self : InstanceFolder) -> String

    server.json: the port, the version and the secret of the server, or the reason why it did not start.

    InstanceFolder::to_repr

    automatically derived

    The links that the server gave and that still work. A link works many times, so a user can open it in a second browser.

    A link works while the time is less than 10 minutes after its issue. If the clock went back, it also works while the time is less than 10 minutes before its issue, and not at an earlier time. A clock that goes back by a day then does not make the link work for a day.

    A link that stopped can work again if the clock of the machine goes back to a time near its issue. This ends at the next issue, which removes the links that do not work at that time.

    Links::empty

    fn Links::empty() -> Links

    No links.

    Links::equal

    fn Links::equal(Links, Links) -> Bool
    automatically derived

    Links::issue

    Adds a link with a new token, and removes the links that do not work at this time, so the number of links does not grow without a limit.

    Links::not_equal

    fn Links::not_equal(x : Links, y : Links) -> Bool
    automatically derived

    Links::redeem

    What the link with this token gives, or None if no link has the token or the link does not work at this time.

    Links::to_repr

    automatically derived

    Platform

    pub(all) enum Platform {
    Windows
    MacOs
    Linux
    } derive(Eq,
    Debug
    )

    The system whose rules read a path and write the paths of its files.

    Port

    A TCP port: a whole number from 1 to 65535.

    Port::Port

    fn Port::Port(value : Int) -> Port raise PortError

    Makes a port from a number from 1 to 65535.

    Port::address

    fn Port::address(self : Port) -> ServerAddress

    The address of a server on this port of the machine. It is also the origin of the UI.

    Port::equal

    fn Port::equal(Port, Port) -> Bool
    automatically derived

    Port::not_equal

    fn Port::not_equal(x : Port, y : Port) -> Bool
    automatically derived

    Port::to_int

    fn Port::to_int(self : Port) -> Int

    Port::to_repr

    automatically derived

    PortChoice

    pub(all) enum PortChoice {
    Fixed(Port)
    Preferred(Port)
    Free
    } derive(Eq,
    Debug
    )

    How an instance finds its port.

    PortChoice::for_command

    The port of a server that a command starts: Fixed for stable, insiders, nightly and dev, and Free for each other instance.

    PortChoice::for_desktop

    The port of a server that the desktop app starts: Preferred for stable, insiders, nightly and dev, and Free for each other instance.

    ProjectList

    type ProjectList derive(Eq,
    Debug
    )

    The projects of an instance, in the order in which the user added them.

    A folder is in the list one time, and an ID is for one project only, also after the project is removed. A list does not change: each operation gives a new list. == compares the paths as FolderPath does.

    ProjectList::add

    Adds a folder at the end of the list, and gives its entry. The new project is not opened. When the folder is in the list, the result is AlreadyListed, the same list and the entry that is there. open sets the time of the last open.

    The function stops the program with abort when the next ID of the list is the largest one, 2147483647, and the folder is new. The list then cannot have a next ID above each ID that was used. Only a project file that a person edited can have such an ID.

    ProjectList::describe

    The details of each project, in the order of the list. state_of says whether the folder of an entry exists.

    A project has a parent while another project has the same name, by the rule of the platform. The parents are there also when they are equal too.

    ProjectList::empty

    fn ProjectList::empty() -> ProjectList

    The list without projects. The first project gets the ID 1.

    ProjectList::entries

    fn ProjectList::entries(self : ProjectList) -> ReadOnlyArray[Entry]

    The entries, in the order in which the user added them.

    ProjectList::equal

    fn ProjectList::equal(ProjectList, ProjectList) -> Bool
    automatically derived

    ProjectList::not_equal

    fn ProjectList::not_equal(x : ProjectList, y : ProjectList) -> Bool
    automatically derived

    ProjectList::of_file_text

    fn ProjectList::of_file_text(text : String, platform : Platform) -> ProjectList raise ProjectFileError

    Reads the text of projects.json. The paths follow the rules of the platform.

    A format above 1 raises NewerFormat, also when the other fields have a form that this version does not know. Each other problem raises Damaged: a text that is not JSON, a field that is missing or has a wrong value, a path that is not absolute, a folder or an ID that is there two times, and a next ID that is not above each ID. A field that is not known has no effect.

    ProjectList::open

    Sets the time of the last open of a project, and gives its new entry. The order of the list does not change.

    ProjectList::remove

    Removes a project from the list, and gives the entry that it had. The list does not use its ID again.

    ProjectList::to_file_text

    fn ProjectList::to_file_text(self : ProjectList) -> String

    The text of projects.json, such as {"format":1,"next":2,"projects":[{"id":1,"path":"/code","added":"5"}]}. A time is a text, as in the app contract. opened is there only for a project that the user opened.

    ProjectList::to_repr

    automatically derived

    ProjectRef

    How a person names a project on the command line.

    find compares a name with the rule of the path of each project: it ignores the case of letters for a project with a Windows path, and compares the exact text for each other project.

    ProjectRef::ProjectRef

    fn ProjectRef::ProjectRef(text : String, current : FolderPath) -> ProjectRef raise ProjectRefError

    Reads the text that a person gives for a project.

    • A text of only the digits 0 to 9 is an ID.
    • A text that is . or .., or that has a separator of the platform, is a path. A relative path starts at the current folder. An absolute path always has a separator.
    • Each other text is a name.

    A folder can have a name of only digits, such as 2026. The text 2026 is then an ID and not this name. Use ./2026 or the ID of the project.

    ProjectRef::equal

    fn ProjectRef::equal(ProjectRef, ProjectRef) -> Bool
    automatically derived

    ProjectRef::find

    Finds the project in the list. NoMatch names the ID, the complete path or the name. The folder of the project can be missing on the disk.

    Names follow the rule of the platform: Windows ignores the case of letters. The path of a project tells the platform, because the list and the current folder are on one machine. A project whose path does not parse is ignored, except when the reference is an ID.

    ProjectRef::not_equal

    fn ProjectRef::not_equal(x : ProjectRef, y : ProjectRef) -> Bool
    automatically derived

    ProjectRef::to_repr

    automatically derived

    RecordDamage

    pub(all) enum RecordDamage {
    NotJson
    NotObject
    BadField(String)
    } derive(Eq,
    Debug
    )

    What is wrong in a damaged record. It never has a value of the record, because the value can be the secret.

    RecordDamage::equal

    automatically derived

    RecordDamage::not_equal

    fn RecordDamage::not_equal(x : RecordDamage, y : RecordDamage) -> Bool
    automatically derived

    RecordDamage::to_repr

    automatically derived

    Secret

    type Secret

    A random text that gives access: the secret of the server, the token of a link, or the cookie value or the view key of a session.

    A secret has no Show and no JSON form, and its debug text is always <secret>, so a log or a failed test does not show it. Only to_text gives the text.
    impl Eq for Secret
    impl Debug for Secret

    Secret::equal

    fn Secret::equal(self : Secret, other : Secret) -> Bool

    Compares as matches does.

    Secret::matches

    fn Secret::matches(self : Secret, text : String) -> Bool

    True when the text is the text of this secret.

    For a text of the same length, the time does not depend on the place of the first difference, so a caller cannot find the secret one character at a time. A text of another length is refused at once: the length is not secret.

    Secret::not_equal

    fn Secret::not_equal(x : Secret, y : Secret) -> Bool

    Secret::of_bytes

    fn Secret::of_bytes(bytes : Bytes) -> Secret raise SecretError

    Makes a secret from 32 random bytes or more. The caller gives the bytes from a random source for cryptography.

    Secret::to_repr

    The same text for each secret, so debug text can go to a log.

    Secret::to_text

    fn Secret::to_text(self : Secret) -> String

    The base64url form of the bytes, without padding. It is safe in an address, a header and a cookie.

    ServerAddress

    type ServerAddress derive(Eq,
    Debug
    )

    The address of a server of this machine, such as http://127.0.0.1:3090.

    ServerAddress::ServerAddress

    fn ServerAddress::ServerAddress(text : String) -> ServerAddress raise AddressError

    Reads an address in the one form that to_string writes.

    ServerAddress::to_string

    fn ServerAddress::to_string(self : ServerAddress) -> String

    ServerRecord

    The content of server.json: how to reach the server of an instance, or why it did not start.

    ServerRecord::equal

    automatically derived

    ServerRecord::not_equal

    fn ServerRecord::not_equal(x : ServerRecord, y : ServerRecord) -> Bool
    automatically derived

    ServerRecord::of_text

    fn ServerRecord::of_text(text : String) -> ServerRecord raise ServerRecordError

    Reads the text that to_text gives. Unknown fields are ignored.

    The format number is read first: a whole number above 1 raises NewerFormat, whatever the other fields are. Each other fault raises Damaged.

    ServerRecord::to_repr

    automatically derived

    ServerRecord::to_text

    fn ServerRecord::to_text(self : ServerRecord) -> String

    The JSON text of the record. The text of a server that runs has its secret, so it must only go to the private file.

    Sessions

    type Sessions derive(Eq,
    Debug
    )

    The sessions that the server gave. A session is valid until the server ends.

    Sessions::add

    Adds a session with a new cookie value and a new view key. The two secrets come from different random bytes: with equal secrets, the cookie is also the key.

    Sessions::empty

    fn Sessions::empty() -> Sessions

    No sessions.

    Sessions::equal

    fn Sessions::equal(Sessions, Sessions) -> Bool
    automatically derived

    Sessions::find

    fn Sessions::find(self : Sessions, name : CookieName, cookie_header : String?) ->
    Surface
    ?

    The kind of view of the session in a Cookie header, or None if the header has no valid session.

    Use this function only for the static page and its script. Another local server can read the cookie, so the cookie alone must not give data or control. The hub and the session check use find_view.

    If the header has several cookies of this name, each one is tried, and the first valid one wins.

    Sessions::find_view

    fn Sessions::find_view(self : Sessions, name : CookieName, cookie_header~ : String?, key~ : String?) ->
    Surface
    ?

    The kind of view of a request for the hub or for the session check, or None if the request does not have the cookie and the view key of one session.

    The cookie of one session with the key of another session gives None. If the header has several cookies of this name, each one is tried with the key.

    Sessions::not_equal

    fn Sessions::not_equal(x : Sessions, y : Sessions) -> Bool
    automatically derived

    Sessions::surface_of

    The kind of view of the session with this view key, or None if no session has it.

    This is not a login. Use it only for a request that find_view accepted, when the cookie is not there any more.

    Sessions::to_repr

    automatically derived

    SiteDecision

    pub(all) enum SiteDecision {
    SameSite
    OtherHost
    OtherOrigin
    } derive(Eq,
    Debug
    )

    Whether a request comes to the address of the server and from its own pages.

    SiteDecision::equal

    automatically derived

    SiteDecision::not_equal

    fn SiteDecision::not_equal(x : SiteDecision, y : SiteDecision) -> Bool
    automatically derived

    SiteDecision::to_repr

    automatically derived

    StartFailure

    pub(all) enum StartFailure {
    PortInUse(Port)
    BadProjectFile(path~ : String, message~ : String)
    Other(String)
    } derive(Eq,
    Debug
    )

    The reason why a server did not start.

    StartFailure::equal

    automatically derived

    StartFailure::not_equal

    fn StartFailure::not_equal(x : StartFailure, y : StartFailure) -> Bool
    automatically derived

    StartFailure::to_repr

    automatically derived

    WaitingProject

    type WaitingProject derive(Eq,
    Debug
    )

    The project that the next window must show, if there is one.

    A start of the desktop app can ask for a project before the page of the window is connected. The project then waits, and the first window that connects takes it.

    WaitingProject::WaitingProject

    A project that waits from this time. Only the last project that a start asked for can wait.

    WaitingProject::equal

    automatically derived

    WaitingProject::none

    No project waits.

    WaitingProject::not_equal

    fn WaitingProject::not_equal(x : WaitingProject, y : WaitingProject) -> Bool
    automatically derived

    WaitingProject::take

    The project for a window that connects at this time, and what waits after it. The distance between the two times counts, as for a link, also when the clock went back. Times are not negative, so it cannot overflow.

    WaitingProject::to_repr

    automatically derived

    desktop_candidates

    fn desktop_candidates(base : BaseFolder, name :
    InstanceName
    , channel :
    Channel
    , env : Map[String, String]) -> ReadOnlyArray[FolderPath]

    The programs that can be the desktop app of an instance, in the order of the search: the one of the variable MISSION_CONTROL_DESKTOP, the app that is installed for the instance, and the app that is installed for the channel of the build. The caller looks which of them is there.

    Each path is complete, because the system looks for a name in the working directory also. So the list does not have a relative path of the variable.

    desktop_program

    fn desktop_program(folder : FolderPath) -> FolderPath

    The path of the program in a folder with an installed desktop app. The names are the ones that Proton gives to the product Mission Control Desktop.

    FolderPath has the rules for the path of each file also.

    desktop_variable

    let desktop_variable : String

    The environment variable with the path of another desktop app.

    last_opened

    The project that the user opened last. For equal times it is the later one in the list. None when the user opened no project.

    linux_data_folder

    fn linux_data_folder(env : Map[String, String]) -> FolderPath raise BaseFolderError

    The folder for the data of the programs of a user on Linux: XDG_DATA_HOME, or .local/share in the home folder. The application menu also reads it.

    nearest_project

    The nearest project that contains the folder: the project folder that is the deepest one. A project whose path does not parse on the platform of the folder is ignored.
    fn set_cookie(name : CookieName, cookie : Secret) -> String

    The value of the Set-Cookie header for a new session. It has the cookie value of the session, and never the view key.

    The cookie has no end time and no domain: the browser keeps it until the browser closes, and sends it to 127.0.0.1 only, but to each port. A script cannot read it, and a request from another site does not have it.

    site_decision

    fn site_decision(port : Port, host~ : String?, origin~ : String?) -> SiteDecision

    Checks the Host and the Origin header of a request to the server on a port. None is an absent header.

    The only host is 127.0.0.1:<port> and the only origin is http://127.0.0.1:<port>, with the exact text. An absent origin is accepted, because a browser does not send it for a page that the user opens. The host is checked first. A browser leaves out the port 80, so a server on that port refuses its requests.