Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::io::Write;
- use bincode::{config, Decode, Encode};
- use pddb::{Pddb, PddbKey};
- const DICT_NAME: &'static str = "irc";
- const USER_NETWORKS_KEY: &'static str = "user_networks";
- const NETWORK_STR_MAX_CHARS: usize = 512;
- #[derive(Encode, Decode, PartialEq, Default, Debug)]
- pub(crate) struct Network {
- pub channel: std::string::String,
- pub server: std::string::String,
- pub nickname: std::string::String,
- }
- #[derive(Encode, Decode, PartialEq, Debug, Default)]
- pub(crate) struct Networks {
- pub networks: Vec<Network>,
- }
- fn store_user_network() {
- let mut pddb = pddb::Pddb::new();
- let mut existing_user_networks: PddbKey = pddb
- .get(
- DICT_NAME,
- USER_NETWORKS_KEY,
- None,
- true,
- true,
- None,
- Some(|| {}),
- )
- .expect("cannot get existing user networks key");
- let mut networks = Networks::default();
- bincode::encode_into_std_write(
- networks,
- &mut existing_user_networks,
- bincode::config::standard().with_big_endian(),
- )
- .expect("cannot store networks");
- }
Advertisement
Add Comment
Please, Sign In to add comment