pub struct Session { /* private fields */ }

Implementations§

Examples found in repository?
src/lib.rs (line 92)
87
88
89
90
91
92
93
    pub fn session(&self, session_name: &str) -> Result<Session, std::io::Error> {
        let session_dir = self.session_dir(session_name);
        if !std::path::Path::new(&session_dir).exists() {
            std::fs::create_dir_all(&session_dir)?;
        }
        Session::new(self, session_name)
    }
Examples found in repository?
src/lib.rs (line 102)
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
    pub fn session_clear(&self, session: &mut Session) -> Result<(), std::io::Error> {
        let session_dir = self.session_dir(session.name());
        session.session_data = None;
        if std::path::Path::new(&session_dir).exists() {
            std::fs::remove_dir_all(&session_dir)?;
        }
        Ok(())
    }
    pub fn session_start(&self, session: &mut Session) {
        let session_dir = self.session_dir(session.name());
        if let Ok(session_data) = Session::new_data(&session_dir) {
            session.session_data = Some(session_data);
        }
    }
    pub fn session_restart(&self, session: &mut Session) -> Result<(), std::io::Error> {
        self.session_clear(session)?;
        self.session_start(session);
        Ok(())
    }
    pub fn update(
        &self,
        session: &mut Session,
        records: Vec<Record>,
    ) -> Result<(), std::io::Error> {
        let session_dir = self.session_dir(session.name());
        if let None = session.session_data {
            if let Ok(session_data) = Session::new_data(&session_dir) {
                session.session_data = Some(session_data);
            }
        }
        if let Some(ref mut session_data) = session.session_data {
            let sequence = session_data.sequence_number.next();
            update::update_recursive(
                self,
                session_data,
                &mut session.temporary_data,
                &session_dir,
                sequence,
                &records,
                None,
            )?;
        }
        Ok(())
    }
Examples found in repository?
src/lib.rs (line 111)
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
    pub fn session_start(&self, session: &mut Session) {
        let session_dir = self.session_dir(session.name());
        if let Ok(session_data) = Session::new_data(&session_dir) {
            session.session_data = Some(session_data);
        }
    }
    pub fn session_restart(&self, session: &mut Session) -> Result<(), std::io::Error> {
        self.session_clear(session)?;
        self.session_start(session);
        Ok(())
    }
    pub fn update(
        &self,
        session: &mut Session,
        records: Vec<Record>,
    ) -> Result<(), std::io::Error> {
        let session_dir = self.session_dir(session.name());
        if let None = session.session_data {
            if let Ok(session_data) = Session::new_data(&session_dir) {
                session.session_data = Some(session_data);
            }
        }
        if let Some(ref mut session_data) = session.session_data {
            let sequence = session_data.sequence_number.next();
            update::update_recursive(
                self,
                session_data,
                &mut session.temporary_data,
                &session_dir,
                sequence,
                &records,
                None,
            )?;
        }
        Ok(())
    }
More examples
Hide additional examples
src/session.rs (line 97)
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
    pub fn new(main_database: &Database, name: impl Into<String>) -> Result<Self, std::io::Error> {
        let mut name: String = name.into();
        assert!(name != "");
        if name == "" {
            name = "untitiled".to_owned();
        }
        let session_dir = main_database.root_dir().to_string() + "/sessions/" + &name;
        if !std::path::Path::new(&session_dir).exists() {
            std::fs::create_dir_all(&session_dir).unwrap();
        }
        let session_data = Self::new_data(&session_dir)?;
        let temporary_data = Self::init_temporary_data(&session_data);
        Ok(Self {
            name,
            session_data: Some(session_data),
            temporary_data,
        })
    }
Examples found in repository?
src/lib.rs (line 235)
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
    pub fn depends(
        &self,
        key: Option<&str>,
        pend_collection_id: i32,
        pend_row: i64,
        session: Option<&Session>,
    ) -> Vec<SessionDepend> {
        let mut r: Vec<SessionDepend> = vec![];
        if pend_row > 0 {
            let depends = self.relation.depends(
                key,
                &CollectionRow::new(pend_collection_id, pend_row as u32),
            );
            for i in depends {
                r.push(i.into());
            }
        } else {
            if let Some(session) = session {
                if let Some(session_depends) = session.depends(key, (-pend_row) as u32) {
                    r = session_depends;
                }
            }
        }
        r
    }

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.