pub struct UserInfo {
pub username: String,
pub home_dir: PathBuf,
pub shell: PathBuf,
pub uid: Option<u32>,
pub gid: Option<u32>,
pub groups: Vec<u32>,
pub display_name: Option<String>,
}Expand description
Information about an authenticated user.
This struct contains user information that is commonly needed after successful authentication, both for client-side display and server-side session setup.
§Examples
use bssh::shared::auth_types::UserInfo;
use std::path::PathBuf;
let user = UserInfo::new("johndoe")
.with_home_dir("/home/johndoe")
.with_shell("/bin/bash")
.with_uid(1000)
.with_gid(1000);
assert_eq!(user.username, "johndoe");Fields§
§username: StringThe username of the authenticated user.
home_dir: PathBufThe user’s home directory.
shell: PathBufThe user’s default shell.
uid: Option<u32>The user’s numeric user ID (Unix-specific).
gid: Option<u32>The user’s primary group ID (Unix-specific).
groups: Vec<u32>Additional group IDs the user belongs to (Unix-specific).
display_name: Option<String>Display name or full name of the user.
Implementations§
Source§impl UserInfo
impl UserInfo
Sourcepub fn new(username: impl Into<String>) -> Self
pub fn new(username: impl Into<String>) -> Self
Create a new UserInfo with just a username.
Other fields are initialized to sensible defaults:
- home_dir:
/home/<username>on Unix, empty on other platforms - shell:
/bin/shon Unix, empty on other platforms - uid/gid: None
§Arguments
username- The username
§Examples
use bssh::shared::auth_types::UserInfo;
let user = UserInfo::new("alice");
assert_eq!(user.username, "alice");Sourcepub fn with_home_dir(self, path: impl Into<PathBuf>) -> Self
pub fn with_home_dir(self, path: impl Into<PathBuf>) -> Self
Set the home directory.
Sourcepub fn with_shell(self, path: impl Into<PathBuf>) -> Self
pub fn with_shell(self, path: impl Into<PathBuf>) -> Self
Set the default shell.
Sourcepub fn with_groups(self, groups: impl Into<Vec<u32>>) -> Self
pub fn with_groups(self, groups: impl Into<Vec<u32>>) -> Self
Set the additional group IDs.
Sourcepub fn with_display_name(self, name: impl Into<String>) -> Self
pub fn with_display_name(self, name: impl Into<String>) -> Self
Set the display name.
Trait Implementations§
impl Eq for UserInfo
impl StructuralPartialEq for UserInfo
Auto Trait Implementations§
impl Freeze for UserInfo
impl RefUnwindSafe for UserInfo
impl Send for UserInfo
impl Sync for UserInfo
impl Unpin for UserInfo
impl UnsafeUnpin for UserInfo
impl UnwindSafe for UserInfo
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreSource§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>
Wrap the input message
T in a tonic::Request