pub struct AsyncIgtlServer { /* private fields */ }
Expand description
Asynchronous OpenIGTLink server
Uses non-blocking I/O with Tokio for high-concurrency scenarios.
§Examples
use openigtlink_rust::io::AsyncIgtlServer;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server = AsyncIgtlServer::bind("127.0.0.1:18944").await?;
let connection = server.accept().await?;
Ok(())
}
Implementations§
Source§impl AsyncIgtlServer
impl AsyncIgtlServer
Sourcepub async fn bind(addr: &str) -> Result<Self>
pub async fn bind(addr: &str) -> Result<Self>
Bind to a local address and create a server asynchronously
§Arguments
addr
- Local address to bind (e.g., “127.0.0.1:18944”)
§Errors
IgtlError::Io
- Failed to bind
§Examples
use openigtlink_rust::io::AsyncIgtlServer;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server = AsyncIgtlServer::bind("127.0.0.1:18944").await?;
Ok(())
}
Sourcepub async fn accept(&self) -> Result<AsyncIgtlConnection>
pub async fn accept(&self) -> Result<AsyncIgtlConnection>
Accept a new client connection asynchronously
§Errors
IgtlError::Io
- Failed to accept connection
§Examples
use openigtlink_rust::io::AsyncIgtlServer;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server = AsyncIgtlServer::bind("127.0.0.1:18944").await?;
let connection = server.accept().await?;
Ok(())
}
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Get the local address this server is bound to
Auto Trait Implementations§
impl !Freeze for AsyncIgtlServer
impl RefUnwindSafe for AsyncIgtlServer
impl Send for AsyncIgtlServer
impl Sync for AsyncIgtlServer
impl Unpin for AsyncIgtlServer
impl UnwindSafe for AsyncIgtlServer
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
Mutably borrows from an owned value. Read more