Skip to main content

SsAccessToken

Struct SsAccessToken 

Source
#[repr(C)]
pub struct SsAccessToken { pub data_size: u32, pub data: [u8], }
Expand description

Equivalent to ACCESSTOKEN in msodbcsql.h. Value of ConnectionAttribute::SS_ACCESS_TOKEN.

Specific to the Microsoft ODBC Driver for SQL Server. A dynamically sized type: pointers to it are fat and carry the length of data, which must equal data_size. Cast to a thin pointer before passing it to the driver.

See: https://learn.microsoft.com/sql/connect/odbc/using-azure-active-directory#authenticating-with-an-access-token

Fields§

§data_size: u32

Length of data in bytes. Does not include a terminating zero.

§data: [u8]

Flexible array member (BYTE data[] in C). Directly follows data_size.

According to Microsoft, a token obtained from an OAuth 2.0 JSON response must be expanded, so each byte is followed by a zero byte. For the ASCII characters of an access token, this equals UTF-16 with little endian byte order. This holds whether the narrow or wide ODBC functions are used, since the driver manager passes the pointer through unchanged.

Implementations§

Source§

impl SsAccessToken

Source

pub fn new(data: &[u8]) -> Box<Self>

data must be the access token in the format expected by the driver: each byte of the ASCII token followed by a zero byte. Use Self::from_text to pass the token text instead.

§Panics

If data is larger than u32::MAX bytes.

Source

pub fn from_text(token: &str) -> Box<Self>

token is the access token as text, e.g. obtained from an OAuth 2.0 JSON response.

§Panics

If the encoded token is larger than u32::MAX bytes.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more