# Documentation

Lean.Server.Rpc.Basic

Allows LSP clients to make Remote Procedure Calls to the server.

The single use case for these is to allow the infoview UI to refer to and manipulate heavy-weight objects residing on the server. It would be inefficient to serialize these into JSON and send over. For example, the client can format an Expr without transporting the whole Environment.

All RPC requests are relative to an open file and an RPC session for that file. The client must first connect to the session using \$/lean/rpc/connect.

An object which RPC clients can refer to without marshalling.

Instances For
Equations
• Objects that are being kept alive for the RPC client, together with their type names, mapped to by their RPC reference.

Note that we may currently have multiple references to the same object. It is only disposed of once all of those are gone. This simplifies the client a bit as it can drop every reference received separately.

aliveRefs :
• Value to use for the next RpcRef. It is monotonically increasing to avoid any possible bugs resulting from its reuse.

nextRef : USize
Instances For
Equations
Equations
Equations
• One or more equations did not get rendered due to their size.
• rpcEncode :
• rpcDecode :

RpcEncodable α means that α can be serialized in the RPC system of the Lean server. This is required when α contains fields which should be serialized as an RPC reference instead of being sent in full. The type wrapper WithRpcRef is used for these fields which should be sent as a reference.

• Any type with FromJson and ToJson instance is automatically RpcEncodable.
• If a type has an Dynamic instance, then WithRpcRef can be used for its references.
• deriving RpcEncodable acts like FromJson/ToJson but marshalls any WithRpcRef fields as Lsp.RpcRefs.
Instances
instance Lean.Server.instRpcEncodable {α : Type} [inst : ] [inst : ] :
Equations
• Lean.Server.instRpcEncodable = { rpcEncode := fun a => pure (), rpcDecode := fun j => }
instance Lean.Server.instRpcEncodableOption {α : Type} [inst : ] :
Equations
• One or more equations did not get rendered due to their size.
instance Lean.Server.instRpcEncodableArray {α : Type} [inst : ] :
Equations
• One or more equations did not get rendered due to their size.
instance Lean.Server.instRpcEncodableProd {α : Type} {β : Type} [inst : ] [inst : ] :
Equations
• One or more equations did not get rendered due to their size.
structure Lean.Server.WithRpcRef (α : Type u) :
• val : α

Marks fields to encode as opaque references in LSP packets.

Instances For
instance Lean.Server.instInhabitedWithRpcRef :
{a : Type u_1} → [inst : ] →
Equations
• Lean.Server.instInhabitedWithRpcRef = { default := { val := default } }
instance Lean.Server.instRpcEncodableWithRpcRef {α : Type} [inst : ] :
Equations
• Lean.Server.instRpcEncodableWithRpcRef = { rpcEncode := Lean.Server.instRpcEncodableWithRpcRef.rpcEncode, rpcDecode := Lean.Server.instRpcEncodableWithRpcRef.rpcDecode }
Equations
Equations
• One or more equations did not get rendered due to their size.