Method: ModelFox::Model.from_bytes
- Defined in:
- lib/modelfox/modelfox.rb
.from_bytes(bytes, options: nil) ⇒ Model
Load a model from bytes instead of a file. You should use this only if you already have a ‘.modelfox` loaded into memory. Otherwise, use `Model.from_path`, which is faster because it memory maps the file.
245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/modelfox/modelfox.rb', line 245 def self.from_bytes(bytes, options: nil) c_model = FFI::MemoryPointer.new(:pointer) c_err = LibModelFox.modelfox_model_from_bytes(bytes, bytes.size, c_model) unless err.null? c_err = FFI::AutoPointer.new(c_err, LibModelFox.method(:modelfox_error_delete)) c_error_s = LibModelFox::ModelFoxStringView.new LibModelFox.(c_err, c_error_s) raise errors.into_string end new(c_model, options: ) end |