You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: aes_gcm.rs
    path of file: ./repos/tock/capsules/aes_gcm/src
    
    the code of the file until where you have to start completion: // Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright Western Digital 2023.

//! Implements an AES-GCM implementation using the underlying
//! AES-CTR implementation.
//!
//! This capsule requires an AES-CTR implementation to support
//! AES-GCM. The implementation relies on AES-CTR, AES-CBC, AES-ECB and
//! AES-CCM to ensure that when this capsule is used it exposes
//! all of sup
    
    fn start_ctr_encrypt(&self) -> Result<(), ErrorCode> {
        self.aes.set_mode_aes128ctr(self.encrypting.get())?;

        let res = AES128::set_key(self.aes, &self.key.get());
        if res != Ok(()) {
            return res;
        }

        self.aes.set_iv(&self.iv.get()).unwrap();

        self.aes.start_message();
        let crypt_buf = self.crypt_buf.take().unwrap();
        let (_aad_offset, message_offset, message_len) = self.pos.get();

        match AES128::crypt(
            self.aes,
            None,
            crypt_buf,
            message_offset,
            message_offset + message_len + AES128_BLOCK_SIZE,
        ) {
            None => {
                self.state.set(GCMState::CtrEncrypt);
                Ok(())
            }
            Some((res, _, crypt_buf)) => {
                self.crypt_buf.replace(crypt_buf);
                res
            }
        }
    }