Struct sbd::directip::Server

source ·
pub struct Server<A: ToSocketAddrs + Sync, S: Storage + Sync + Send> { /* private fields */ }
Expand description

A Iridium DirectIP server.

The server will listen on a socket address for incoming Iridium SBD Mobile Originated messages. Incoming messages will be stored using sbd::filesystem::Storage. Errors are logged using the logging framework.

Implementations§

source§

impl<A, S> Server<A, S>where A: ToSocketAddrs + Sync, S: 'static + Storage + Sync + Send,

source

pub fn new(addr: A, storage: S) -> Server<A, S>

Creates a new server that will listen on addr and write messages to storage.

This method does not actually bind to the socket address or do anything with the storage. Use bind and serve_forever to actually do stuff.

The provided storage is expected to be ready to accept new messages.

Examples
let storage = sbd::storage::MemoryStorage::new();
let server = sbd::directip::Server::new("0.0.0.0:10800", storage);
source

pub fn bind(&mut self) -> Result<()>

Binds this server to its tcp socket.

This is a seperate operation from serve_forever so that we can capture any errors associated with the underlying TcpListener::bind.

Examples
let storage = sbd::storage::MemoryStorage::new();
let mut server = sbd::directip::Server::new("0.0.0.0:10800", storage);
server.bind().unwrap();
source

pub fn serve_forever(self)

Starts the DirectIP server and serves forever.

Panics

This method panics if it has a problem binding to the tcp socket address. To avoid a panic, use Server::bind before calling Server::serve_forever.

Examples
let storage = sbd::storage::MemoryStorage::new();
let mut server = sbd::directip::Server::new("0.0.0.0:10800", storage);
server.bind().unwrap();
server.serve_forever();

Trait Implementations§

source§

impl<A: Debug + ToSocketAddrs + Sync, S: Debug + Storage + Sync + Send> Debug for Server<A, S>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<A, S> RefUnwindSafe for Server<A, S>where A: RefUnwindSafe,

§

impl<A, S> Send for Server<A, S>where A: Send,

§

impl<A, S> Sync for Server<A, S>

§

impl<A, S> Unpin for Server<A, S>where A: Unpin,

§

impl<A, S> UnwindSafe for Server<A, S>where A: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.