[go: up one dir, main page]

schannel 0.1.10

Schannel bindings for rust, allowing SSL/TLS (e.g. https) without openssl
Documentation
use winapi::shared::sspi;
use std::ops::Deref;
use std::slice;

pub struct ContextBuffer(pub sspi::SecBuffer);

impl Drop for ContextBuffer {
    fn drop(&mut self) {
        unsafe {
            sspi::FreeContextBuffer(self.0.pvBuffer);
        }
    }
}

impl Deref for ContextBuffer {
    type Target = [u8];

    fn deref(&self) -> &[u8] {
        unsafe { slice::from_raw_parts(self.0.pvBuffer as *const _, self.0.cbBuffer as usize) }
    }
}