pub struct Server { /* private fields */ }Expand description
The reovim server.
Manages sessions and handles client connections via the configured transport.
Implementations§
Source§impl Server
impl Server
Sourcepub fn new(config: ServerConfig) -> Self
pub fn new(config: ServerConfig) -> Self
Create a new server with the given configuration.
This creates a server with empty registries. For full vim functionality,
use Server::with_services or Server::with_session_factory to
inject module-initialized registries.
Sourcepub fn with_services(
config: ServerConfig,
services: Arc<ServiceRegistry>,
) -> Self
pub fn with_services( config: ServerConfig, services: Arc<ServiceRegistry>, ) -> Self
Create a server with a service registry populated by modules.
The service registry should contain:
ResolverRegistry- mode key resolversKeybindingStore- keybindingsCommandHandlerStore- command handlersModeInfoStore- mode metadata
§Example
use reovim_server::{Server, ServerConfig};
use reovim_kernel::api::v1::ServiceRegistry;
// Bootstrap: load modules and populate services
let services = Arc::new(ServiceRegistry::new());
bootstrap_modules(&services);
let server = Server::with_services(ServerConfig::default(), services);
server.run().await?;Sourcepub fn with_session_factory(
config: ServerConfig,
factory: SessionFactory,
) -> Self
pub fn with_session_factory( config: ServerConfig, factory: SessionFactory, ) -> Self
Create a server with a custom session factory.
The factory function is called each time a new session is created,
allowing the runner to inject fully-configured SessionState instances
with module-initialized registries.
This is the most flexible option for module integration.
§Example
use reovim_server::{Server, ServerConfig, SessionState};
let server = Server::with_session_factory(
ServerConfig::default(),
Box::new(|| {
// Create session state with populated registries
create_session_state_with_modules()
}),
);
server.run().await?;Sourcepub fn with_bridges(self, registry: BridgeRegistry) -> Self
pub fn with_bridges(self, registry: BridgeRegistry) -> Self
Set the extension bridge registry (#468).
Bridges are collected from BridgeProvider in bootstrap.
Must be called before run().
Sourcepub async fn run(&self) -> Result<()>
pub async fn run(&self) -> Result<()>
Run the server.
This method blocks until the server is shut down.
§Errors
Returns an error if the transport fails to start (e.g., port in use).
Sourcepub async fn run_until(
&self,
shutdown: impl Future<Output = ()> + Send + 'static,
port_tx: Option<Sender<u16>>,
) -> Result<()>
pub async fn run_until( &self, shutdown: impl Future<Output = ()> + Send + 'static, port_tx: Option<Sender<u16>>, ) -> Result<()>
Run the server until a shutdown signal is received.
Similar to run() but accepts a shutdown future and an optional
port sender. When the shutdown future resolves, the server performs a graceful
shutdown. The port sender reports the actual bound port (useful when binding
to port 0 for OS-assigned ports).
Only gRPC transport is supported.
§Errors
Returns an error if the transport fails to start or if the configured transport is not gRPC.
Sourcepub const fn sessions(&self) -> &Arc<SessionRegistry>
pub const fn sessions(&self) -> &Arc<SessionRegistry>
Get a reference to the session registry.
Auto Trait Implementations§
impl Freeze for Server
impl !RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnsafeUnpin for Server
impl !UnwindSafe for Server
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request