pub struct CortexServer { /* private fields */ }Expand description
The Córtex API Server.
This struct encapsulates the server’s configuration and shared state, and provides methods to build the router and run the server.
Implementations§
Source§impl CortexServer
impl CortexServer
Sourcepub fn new(config: CortexConfig) -> Result<Self>
pub fn new(config: CortexConfig) -> Result<Self>
Creates a new CortexServer with a given configuration.
The graph database backend is selected based on config.db_path:
Some(":memory:")— volatile in-memory storage.Some(path)— Sled-backed persistent storage at the given path.None— Sled-backed persistent storage at~/.aingle/cortex/graph.sled.
Sourcepub fn with_state(config: CortexConfig, state: AppState) -> Self
pub fn with_state(config: CortexConfig, state: AppState) -> Self
Creates a new CortexServer with a given configuration and a pre-existing AppState.
Sourcepub fn state_mut(&mut self) -> &mut AppState
pub fn state_mut(&mut self) -> &mut AppState
Returns a mutable reference to the shared AppState.
Sourcepub fn build_router(&self) -> Router
pub fn build_router(&self) -> Router
Builds the axum router, combining all API routes and middleware.
Auto Trait Implementations§
impl Freeze for CortexServer
impl !RefUnwindSafe for CortexServer
impl Send for CortexServer
impl Sync for CortexServer
impl Unpin for CortexServer
impl UnsafeUnpin for CortexServer
impl !UnwindSafe for CortexServer
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more