This version of the module is deprecated: This package is deprecated. moonbit-community/proton should be preferred.

    #proton/ipc

    justjavac/proton/ipc defines transport-neutral protocol types for Proton.

    It does not know about WebView, WebSocket, process launch, or extension code. The current root facade uses these types with the native DLL bridge.

    IpcError

    pub(all) suberror IpcError {
    MalformedJson(detail~ : String)
    InvalidPayload(kind~ : String, detail~ : String)
    UnsupportedVersion(scope~ : String, actual~ : Int, supported~ : Int)
    UnsupportedFrameKind(kind~ : String)
    UnexpectedFrameKind(expected~ : String, actual~ : String)
    EmptyField(path~ : String)
    InvalidErrorResponseBody
    } derive(Eq,
    Debug
    )

    Failures while decoding or validating Proton IPC protocol values.

    IpcError::message

    fn IpcError::message(self : IpcError) -> String

    IpcExtensionApi

    pub(all) struct IpcExtensionApi {
    api_name : String
    } derive(Eq, ToJson,
    Debug
    ,
    FromJson
    )

    One JavaScript-facing API exposed for a remote extension namespace.

    IpcExtensionApi::new

    fn IpcExtensionApi::new(api_name : String) -> IpcExtensionApi

    Creates one remote extension API descriptor.

    IpcExtensionDescriptor

    pub(all) struct IpcExtensionDescriptor {
    id : String
    js_namespace : String
    apis : Array[IpcExtensionApi]
    scripts : Array[String]
    } derive(Eq, ToJson,
    Debug
    ,
    FromJson
    )

    JavaScript bridge metadata for one remote extension.

    IpcExtensionDescriptor::new

    fn IpcExtensionDescriptor::new(id : String, js_namespace : String, apis : Array[IpcExtensionApi], scripts? : Array[String]) -> IpcExtensionDescriptor

    Creates one remote extension bridge descriptor.

    IpcExtensionEvent

    pub(all) struct IpcExtensionEvent {
    version : Int
    extension_namespace : String
    event_name : String
    payload : Json
    } derive(Eq, ToJson,
    Debug
    ,
    FromJson
    )

    One extension event sent from the user process to JavaScript.

    IpcExtensionEvent::new

    fn IpcExtensionEvent::new(extension_namespace : String, event_name : String, payload : Json) -> IpcExtensionEvent

    Creates one extension event IPC frame.

    IpcExtensionEvent::validate

    Validates one decoded extension event.

    IpcFrame

    pub(all) struct IpcFrame {
    version : Int
    kind : String
    payload : Json
    } derive(Eq, ToJson,
    Debug
    ,
    FromJson
    )

    One protocol envelope exchanged by a concrete IPC transport.

    IpcFrame::as_event

    fn IpcFrame::as_event(self : IpcFrame) -> IpcExtensionEvent raise IpcError

    Decodes this frame as an extension event.

    IpcFrame::as_request

    fn IpcFrame::as_request(self : IpcFrame) -> IpcOpRequest raise IpcError

    Decodes this frame as an operation request.

    IpcFrame::as_response

    fn IpcFrame::as_response(self : IpcFrame) -> IpcOpResponse raise IpcError

    Decodes this frame as an operation response.

    IpcFrame::event

    fn IpcFrame::event(event : IpcExtensionEvent) -> IpcFrame

    Wraps an extension event in a transport frame.

    IpcFrame::request

    fn IpcFrame::request(request : IpcOpRequest) -> IpcFrame

    Wraps an operation request in a transport frame.

    IpcFrame::response

    fn IpcFrame::response(response : IpcOpResponse) -> IpcFrame

    Wraps an operation response in a transport frame.

    IpcFrame::stringify

    fn IpcFrame::stringify(self : IpcFrame) -> String

    Serializes one transport frame.

    IpcFrame::validate

    fn IpcFrame::validate(self : IpcFrame) -> IpcFrame raise IpcError

    Validates one decoded transport frame envelope.

    IpcOpRequest

    pub(all) struct IpcOpRequest {
    version : Int
    id : String
    name : String
    payload : Json
    } derive(Eq, ToJson,
    Debug
    ,
    FromJson
    )

    One operation invocation sent from the JavaScript bridge to the user process.

    IpcOpRequest::new

    fn IpcOpRequest::new(id : String, name : String, payload : Json) -> IpcOpRequest

    Creates one operation request frame.

    IpcOpRequest::stringify

    fn IpcOpRequest::stringify(self : IpcOpRequest) -> String

    Serializes an operation request as one JSON IPC payload.

    IpcOpRequest::validate

    fn IpcOpRequest::validate(self : IpcOpRequest) -> IpcOpRequest raise IpcError

    Validates one decoded operation request.

    IpcOpResponse

    pub(all) struct IpcOpResponse {
    version : Int
    id : String
    status : Int
    body : Json
    } derive(Eq, ToJson,
    Debug
    ,
    FromJson
    )

    One operation completion sent from the user process back to JavaScript.

    status == 0 means success. Any non-zero status means body contains a JSON string error message suitable for rejecting the JavaScript promise.

    IpcOpResponse::err

    fn IpcOpResponse::err(id : String, message : String) -> IpcOpResponse

    Creates one failed operation response frame.

    IpcOpResponse::is_ok

    fn IpcOpResponse::is_ok(self : IpcOpResponse) -> Bool

    Returns whether this response represents success.

    IpcOpResponse::ok

    fn IpcOpResponse::ok(id : String, body : Json) -> IpcOpResponse

    Creates one successful operation response frame.

    IpcOpResponse::stringify

    fn IpcOpResponse::stringify(self : IpcOpResponse) -> String

    Serializes an operation response as one JSON IPC payload.

    IpcOpResponse::validate

    fn IpcOpResponse::validate(self : IpcOpResponse) -> IpcOpResponse raise IpcError

    Validates one decoded operation response.

    parse_ipc_frame

    fn parse_ipc_frame(raw : String) -> IpcFrame raise IpcError

    Parses one JSON IPC transport frame.

    parse_ipc_op_request

    fn parse_ipc_op_request(raw : String) -> IpcOpRequest raise IpcError

    Parses one JSON IPC operation request.

    parse_ipc_op_response

    fn parse_ipc_op_response(raw : String) -> IpcOpResponse raise IpcError

    Parses one JSON IPC operation response.

    protocol_version

    fn protocol_version() -> Int

    Returns the protocol version used in all IPC envelopes and payloads.