Initialize

Function Initialize 

Source
pub fn Initialize(
    ApplicationHandle: AppHandle,
    MountainAddressString: String,
    CocoonAddressString: String,
) -> Result<(), VineError>
Expand description

Initializes and starts the gRPC servers on background tasks.

This function retrieves the core ApplicationRunTime from Tauri’s managed state, instantiates the gRPC service implementations (MountainVinegRPCService and CocoonServiceServer), and uses tonic to serve them at the specified addresses.

§Parameters

  • ApplicationHandle: The Tauri application handle
  • MountainAddressString: The address and port to bind the Mountain server to (e.g., "[::1]:50051")
  • CocoonAddressString: The address and port to bind the Cocoon server to (e.g., "[::1]:50052")

§Returns

  • Ok(()): Successfully initialized and started both servers
  • Err(VineError): Initialization failed (invalid address, missing runtime, etc.)

§Errors

This function will return an error if:

  • Either socket address string is invalid or unparseable
  • ApplicationRunTime is not available in Tauri state
  • Server task spawning fails (rare)

§Example

Initialize(handle, "[::1]:50051".to_string(), "[::1]:50052".to_string())?;

§Notes

  • Servers run as detached tokio tasks
  • Initialization is async-safe but function is synchronous
  • Servers log errors independently after startup
  • Use Default addresses for development (localhost with default ports)